Declaring Entity FrameWork Contexts with using

前端 未结 3 1996
广开言路
广开言路 2021-02-08 09:40

Which is the Best Practise in Declaring Entity FrameWork Contexts

function()
{
    DBContext context = new DBContext();

    //Entity code

    return ;
}
         


        
3条回答
  •  孤独总比滥情好
    2021-02-08 10:34

    You can avoid the lazy-loading EF behaviour by calling .ToList() on the IEnumerable before the context is disposed (i.e. within your using block)

提交回复
热议问题