c# entity framework: correct use of DBContext class inside your repository class

前端 未结 10 1600
伪装坚强ぢ
伪装坚强ぢ 2020-12-02 10:59

I used to implement my repository classes as you can see below

public Class MyRepository
{
      private MyDbContext _context; 

      public MyRepository(My         


        
10条回答
  •  自闭症患者
    2020-12-02 11:40

    Second approach (using) is better as it surely holds the connection only for the minimum needed time and is easier to make thread-safe.

提交回复
热议问题