vb.net - Tuning Entity Framework - dbContext? -


itemprop = "text">

I have some model classes:

  public class MyViewModel public property MyID () integer Go into the form of Folk ReadOnly Property FirstList IEnumerable (SelectListItem) as the new MyContext dim itemQuery form using dbContext = (d in T. dbContext.ItemSet T) Dim Item IEnumerable (item) = itemQuery.ToList () return item. Select (function as O) New SelectListItem () {.text = o.ItemDesc, .Value = o.ID}) End assets publicly readOnly property using second end Go to SecondList using IEnumerable (as selectListItem) using the dbContext as the new MyContext _actu (get from dbContext.FrameworkSet in T.) IEnumerable (ITEM2) = _Query.ToList () Return _list.Select (Function (o) {.text = o.Item2Desc, .Value = o.ID as _list slow}) and end and end and property and class with new SelectListItem ()   

Actually, I am calling MyContext twice, it instantiates EF repeatedly, right? So my idea is just a square global

  dim dbContext as new MyContext   

In addition to the code analysis I need to apply I need to implement IDisposable

I am confused - is the best practice acceptable?

itemprop = "text">

after comment (s), which, in a nutshell, are not referring context in a global variable And prefer short-term disposable references in return) except that I want to point out that most of the references were not done according to the creation of the initial thing but were done once for the lifetime of the application. This is primarily the process of building your internal model, which it does and then caches.

See more details here:

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -