Returns Enumerable.Empty <T> (). Is AsQueryable () a bad idea?
This is probably best explained by some code:
public IQueryable<DatabaseRecord> GetQueryableLinkedRecords()
{
if(this.currentlyHeldIds.Count() == 0)
{
return Enumerable.Empty<DatabaseRecord>().AsQueryable();
}
else
{
return from r in this.DBContext.DatabaseRecords
where this.currentlyHeldIds.Contains(r.Id)
select r;
}
}
The idea is that there is no reason to really request db again if there is currently no onHeldId request. LINQ to SQL will still query db if nowHeldIds doesn't matter. Is there something wrong with this approach? I understand that there are some other problems associated with returning IQueryable in general, but these arguments are aloof, is there something wrong with trying to get around the db call like this?
+5