Multiple/single instance of Linq to SQL DataContext

后端 未结 5 685
遥遥无期
遥遥无期 2020-12-01 00:04

I have a project with a number of different classes querying and modifying data in a common set of tables. I\'ve set up a .dbml file which provides us with a DataContext cla

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-01 00:50

    The DataContext class is lightweight enough that you can instantiate it over and over. This makes thing simpler when accessing entity objects within a single method. If you need to access the same LINQ objects from different classes and methods while keeping them attached to the DataContext for tracking purposes, it's also okay to keep a single instance.

提交回复
热议问题