Simplified repeated code for each entity type is
public IList<entity1> GetEntity1(.. query params ..)
{
IQueryable<entity1> query = context.entity1;
query = from refDataType in query
where refDataType.Id > 0
select refDataType;
.
. plus more changes to query same for each entity
.
return query.ToList();
}
I wanted to create a generic function that creates the query, but not sure how to go about it?
ie in the following snippet, How do I code for ReturnAGenericQuery?
public IList<entity1> GetEntity1(.. query params ..)
{
IQueryable<entity1> query = context.entity1;
query = ReturnAGenericQuery of type entity1
return query.ToList();
}
public IList<entity2> GetEntity2(.. query params ..)
{
IQueryable<entity2> query = context.entity2;
query = ReturnAGenericQuery of type entity2
return query.ToList();
}
private IQueryable<T> ReturnAGenericQuery<T> ()
{
return IQueryable of entity1 or entity2
}