I have html extensions and am trying to use my repository list I have for select lists. In my controllers I have the unit of work pattern and am disposing it properly with the dispose method but in the html extensions I need to know how to dispose my list repository.
I tried the following but when I get back to my view it says the context has been disposed.
I don't need to implement my uow in my html extensions because I only need my list repository.
public static Kendo.Mvc.UI.Fluent.MultiSelectBuilder ClientAccountMultiSelectFor<TModel, TValue>(this HtmlHelper<TModel> html,
Expression<Func<TModel, TValue>> expression, string id)
IQueryable<ClientAccountViewModel> clientAccounts = null;
using (Entities entities = new Entities())
clientAccounts = new ListRepository(entities).GetClientAccountList("0", null, false).AsQueryable();
.BindTo(new SelectList(clientAccounts, "ClientAccountID", "AccountName"));
I get the following error that I think I can resolve if I can dispose my repository and close the connection, I think I'm getting this error because I'm opening too many connections and not disposing them.
Error in "EntityFramework" application
Error Type: System.InvalidOperationException
Error Message: The underlying provider failed on Open.