Exposing IQueryable<T>
through your BL does not expose your DAL. Since you want to encapsulate the database entities in separate classes for the application layer, you can still do this, although the application will be more limited in the types of queries it can run.
// DAL
public class Entity { ... }
// BL
public class EntityInfo : Entity { ... }
...
public IQueryable<EntityInfo> GetEntities()
{
return from e in dbContext.Entities
select new EntityInfo
{
// populate your application layer object
}
}
Here's an alternative way of coding it that provides the same result
public Expression<Func<Entity, EntityInfo>> materializeEntityInfo =
e => new EntityInfo { .. };
public IQueryable<EntityInfo> GetEntities()
{
return dbContext.Entities.Select(materializeEntityInfo);
}