nhibernateirepository

How can I use Expression<T> in NHibernate?


I have read the very good blog post of Rob Conery Crazy Talk: Reducing ORM Friction
How can I generalize this interface so I can implement it with NHibernate?

using System;  
using System.Collections;  
using System.Linq;  
using System.Linq.Expressions;   


public interface IRepository<T>   
{  
     IQueryable<T> GetAll();  
     PagedList<T> GetPaged(int pageIndex, int pageSize);  
     IQueryable<T> Find(Expression<Func<T, bool>> expression);  
     void Save(T item);  
     void Delete(T item);  
}  

I want to use the Expression<Func<T, bool>> expression in NHibernate. Any clue?


Solution

  • Look at LINQ to NHibernate. Kyle Baley has a great overview of it