2

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?

swilliams
  • 48,060
  • 27
  • 100
  • 130
Mariano
  • 2,928
  • 6
  • 25
  • 28

2 Answers2

3

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

Ryan Rinaldi
  • 4,119
  • 2
  • 22
  • 22
0

You'll need to walk the expression tree and build your Criteria.

jonnii
  • 28,019
  • 8
  • 80
  • 108