Add Item to Linq without saving it to the db
Hi I need to add an item to my current context bu开发者_如何转开发t I need this item to be reflected when I add it without saving changes, when I use
Jobs newJob=new Jobs();
context.Jobs.AddObject(newJob);
var x= from c in context.Jobs select c;
gridControl.DataSource=x;
Then the grid doesn't have the new value, It would have the value if I used context.SaveChanges(); before binding the data. Any suggestions for this issue?
Thanks in advance
It looks like you should use a intermediate data store like a list:
var jobs = context.Jobs.ToList();
Jobs newJob = new Jobs();
jobs.Add(newJob);
gridControl.DataSource = jobs;
精彩评论