I'm trying to do something similar in Entity Framework, that I'm very used to doing in Linq-To-Sql. Now my question is if EF has the same capability, that I'm unable to figure out.
Linq-To-Sql:
dataContext.GetTable<T>();
Would yield a Queryable collection of type 'T'.
In Entity Framework I would like to do the same:
//NOTICE: This is a partial extension of the auto-generated Entities-model
// created by the designer.
public partial class Entities : IEntities
{
public IQueryable<T> FindAll<T>()
{
//pseudo-code
// return from all entities, the entities that are of type T as Queryable
}
}
Since I wasn't able to figure this out, I made, what I consider, a "smelly" work-around:
//NOTICE: This is a partial extension of the auto-generated Entities-model
// created by the designer.
public partial class Entities : IEntities
{
public IQueryable<Users> FindAllUsersQueryable
{
get { return Users; }
}
public IQueryable<Registrations> FindAllRegistrationsQueryable
{
get { return Registrations; }
}
//... and so on ...
}
What I want is something similar to:
//NOTICE: This is a partial extension of the auto-generated Entities-model
// created by the designer.
public partial class Entities : IEntities
{
public IQueryable<T> FindAll<T>()
{
return GetEntities<T>();
}
}
But so far I haven't been able to find out how to do that.
Anyone got a tip?