I have a repository class that has a method to return ObjectSet
something like
public class Repository:ObjectContext
{
public IObjectSet<T> GetObjectSet()
{...}
}
When I use this in a query I get linq to entities error ( does not recognize method...)
I like this idea of having a generic repository which doesn't get regenerated every time (with T4 templates) Is there a way to extend the query provider to recognize my method ? But I do want to resolve it on server ( in other words participate in query generation). Sample code that uses it is:
static readonly Func<Repository,
string, AuthorizedUser> getInstitutionByAuthorizedUserName = CompiledQuery.Compile(
(ObjectContext ctx, string userName) =>
(from inst in ctx.GetObjectSet<Institution>()
join auths in ctx.GetObjectSet<AuthorizedUser>()
on inst.Key equals auths.Institution.Key
where auths.Name == userName
select inst.Key).SingleOrDefault();