Given i have a class like so in my Data Layer
public class GenericRepository<TEntity> where TEntity : class
{
public MyDataContext DataContext {get;set;}
[System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Select)]
public IQueryable<TEntity> SelectAll()
{
return DataContext.GetTable<TEntity>();
}
}
I would be able to query a table in my database like so from a higher layer
using (GenericRepositry<MyTable> mytable = new GenericRepositry<MyTable>())
{
var myresult = from m in mytable.SelectAll()
where m.IsActive
select m;
}
is this considerably slower than using the usual code in my Data Layer
using (MyDataContext ctx = new MyDataContext())
{
var myresult = from m in ctx.MyTable
where m.IsActive
select m;
}
Eliminating the need to write simple single table selects in the Data layer saves a lot of time, but will i regret it?
Edit: @ Skeet I have actually implemented this approach in a fairly large WCF/Silverlight LOB project, and it seems our servers CPU's are struggling to keep up. The extra work of creating/destroying extra objects couldn't possibly be attributed to the rise in cpu usage over projects using the usual way?