LINQ to SQL: Multiple / Single .dbml per project?

后端 未结 7 1156
悲哀的现实
悲哀的现实 2020-12-14 11:12

I\'ve read Rick Strahl\'s article on Linq to SQL DataContext Lifetime Management hoping to find some answers on how I would manage my .dbml files since they are so closely r

7条回答
  •  北荒
    北荒 (楼主)
    2020-12-14 11:25

    Another thing to bear in mind is that LINQ uses the DataContext to track the identities of the instances of entities it creates. Therefore, an entity representing a row in a table created by one instance of the DataContext class is not the same as one created by another, even if all the properties are the same.

    When one has multiple DBML files, then by necessity, there will be multiple instances of DataContexts, one for each DBML file. Therefore, entities can't be joined or shared from one DataContext to another.

    This is applicable when an entity exists in both (or all) DBML files.

提交回复
热议问题