Skip to content Skip to sidebar Skip to footer

Can Context Of Entity Framework Be Extracted From Object Later On?

Considering that I use code like (with or without using (considering that using(??) may dispose context)): IQueryable listaKonsultantow; using (var context = new

Solution 1:

Since you dispose your context at the end of the using block you should not even try.

Solution 2:

Separating the context out as a concern will lead down the path of many design patterns that will interest you. You should definitely look into repositories and dependency injection (unity is MS's DI Container which helps to manage dependencies such as the data context issue you are having). If these topics are beyond the scope of your project, then re-typing your using statement is probably not a concern.

Post a Comment for "Can Context Of Entity Framework Be Extracted From Object Later On?"