I have a pretty simple ActionResult function that is called from my view and it receives a number from it, I want to add this much new rows in my database equals to that number and the only column I fill in is the id of the formation it is related to, here is my code as of now
public ActionResult AddInfo(int? idfrm,int? NumberToAdd)
{
using (InscriptionFormationEntities dbm = new InscriptionFormationEntities())
{
for(int i=0;i<NumberToAdd;i++)
{
INSC_MoreInfo NewEntry= new INSC_MoreInfo ();
NewEntry.idformation = idfrm;
dbm.INSC_MoreInfo .Add(info);
}
dbm.SaveChanges();
}
return View(idfrm);
}
The code above works perfectly but I was wondering if there was a way to arrive at the same result without relying on a for loop since it could be slow if for example the number of new entry to make is really big ( it could very well be in this case)
**Note:**My project is made in asp.net mvc 5,my code is database first and I use Entity framework to connect with it