开发者

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;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜