I have some short code that looks like this:
public static IQueryable<User> SelectFromEmployee(int employee)
{
using (var ctx = Database.AccountingContext())
{
return ctx.Users.Where(c => c.Employee_FK == employee);
}
}
If i just keep this code as it is and use the result i get en exception telling me that the data is disposed. But if I do like this:
public static IEnumerable<User> SelectFromEmployee(int employee)
{
using (var ctx = Database.AccountingContext())
{
return ctx.Users.Where(c => c.Employee_FK == employee).ToList();
}
}
Everything works just fine. But my problem is that i want to use Linq Dynamic that require IQueryable. Is there any way to return a local IQueryable so i can continue working with it?