for inserting values to database in wcf ria services we use the following code,
public void InsertFormCaption(FormCaption formCaption)
{
if ((formCaption.EntityState != EntityState.Detached))
{
this.ObjectContext.ObjectStateManager.ChangeObjectState(formCaption, EntityState.Added);
}
else
{
this.ObjectContext.FormCaptions.AddObject(formCaption);
}
}
in code:
FormCaption tblcaption=new FormCaption;
tblcaption.FormID = frmid;
ctx.FormCaptions.Add(tblcaption);
ctx.SubmitChanges();
This will work and add a single element to database. i mean a single row to Formcaption table.
My question is how can i add multiple datas at a time to databse? i need to add two rows to table FormCaption with two CaptionName values. Can anyone help?
(sorry for my bad english)
You can add as many objects as you want on FormCaptions before call SubmitChanges() and when you call it, all objects will be sended to server and saved.