LinqToSql static DataContext in a web application

后端 未结 5 1131
囚心锁ツ
囚心锁ツ 2021-01-02 12:14

In a web application that I have run across, I found the following code to deal with the DataContext when dealing with LinqToSQL

public partial class DbDataC         


        
5条回答
  •  天命终不由人
    2021-01-02 12:33

    I have done many Linq to Sql web apps and I am not sure if what you have would work.

    The datacontext is supposed to track the changes you make to your objects and it will not do that in this instance.

    So when you go hit submit changes, it will not know that any of your objects where updated, thus not update the database.

    You have to do some extra work with the datacontext in a disconnected environment like a web application. It is hardest with an update, but not really that bad. I would not cache and just recreate it.

提交回复
热议问题