New Posts New Posts RSS Feed: Update multiple records
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Update multiple records

 Post Reply Post Reply
Author
new user View Drop Down
Newbie
Newbie


Joined: 18-May-2011
Posts: 7
Post Options Post Options   Quote new user Quote  Post ReplyReply Direct Link To This Post Topic: Update multiple records
    Posted: 18-May-2011 at 11:54pm
Hello Sbelini,

Thanks alot..it is worked for me...:)

Thanks once again...
Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 18-May-2011 at 10:08am
Hi,
 
If you already have an ObservableCollection of Employees, why are you requerying one at time again?
Also, you don't need to call SaveChagesAsync to each Employee.
 
Try this instead:
 
foreach (Employee emp in SelectedEmployees)//where 'SelectedEmployees' is a observablecollection of type 'Employee'
{
  emp.EmpName = "new name";
}
manager.SaveChangesAsync();
Silvio.
 
Back to Top
new user View Drop Down
Newbie
Newbie


Joined: 18-May-2011
Posts: 7
Post Options Post Options   Quote new user Quote  Post ReplyReply Direct Link To This Post Posted: 18-May-2011 at 8:35am
Hello friends,

My requirement is to update multiple records in Employee entity using IdeaBlade. I have tried following code snippet. But it is updating only one record in Employee entity. Can anyone help me please. Its urgent.

 foreach (Employee emp in SelectedEmployees)//where 'SelectedEmployees' is a observablecollection of type 'Employee'
                    {
                       var empQuery = mgr.Employees.AsScalarAsync().First(i => i.EmpID == emp.EmpID);
                       empQuery.Completed += (o, i) =>
                        {
                            Employee newEmp =  i.Result;
                            newEmp.EmpName = "new name";
                            newEmp.EntityAspect.AddToManager();
                            manager.SaveChangesAsync();
                       };
                  }
                        
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down