开发者

LINQ DataContext

I am new to LINQ and have to write several LINQ operations within a single method. I am wondering if they should all refer to a single LinqToSQLClassesDataContext, or whether each operation needs a separate LinqToSQLClassesDataContext? And if they can use the same LinqToSQLClassesDataContext, is there some operation t开发者_如何学编程hat needs to be done to reset it before using it for something else?


You should have no problem creating one context at the top of your method, and using it throughout your method. Just make sure you dispose of it when you are done.

After each operation you should call context.SubmitChanges() to save any changes back to the database.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜