Reputation: 177
I have an MVC4, EF web application.
I have a data access class ("db_calls") that has all my methods for data access.
In each of my controllers I instantiate this class once with:
private db_calls dbcalls = new db_calls();
This "db_calls" class instantiates the dbcontext in order to work with the data like so:
private MyContext db = new MyContext ();
I have 3 questions:
My concern is that I am going to have a load of objects floating about that I dont need.
Upvotes: 0
Views: 51
Reputation: 2387
I think whenever you use the "new" keyword a new object is created in memory.
Also I think your case is not too much non-optimized.
Upvotes: 1