views:

33

answers:

2

I have mapped a simple entity, let's say an invoice using Fluent NHibernate, everything works fine... after a while it turns out that very frequently i need to process 'sent invoices' (by sent invoices we mean all entities that fulfill invoice.sent==true condition)... is there a way to easily abstract 'sent invoices' in terms of my data access layer? I dont like the idea of having aforementioned condition repeated in half of my repository methods. I thought that using a simple filtering view would be optimal, but how could it be done? Maybe I am doing it terribly wrong and someone would help me realize it :)?

A: 

Personally I would just live with the extra methods on your repository.

UpTheCreek
Hmm yes its just you repeat same condition over and over and thats certainly not a good idea, especially if anything in it changes :)
adrin
A: 

Although I'd personally use repository methods, you can do this with NHibernate filters, which exist exactly for this purpose.

Diego Mijelshon
Yes thanks for suggestion, I've stumbled upon NH filters and indeed it can serve this purpose well... but as you and Sosh suggested i will probably stick with repository methods.
adrin