Repository taking linq expression for filtering -


I am considering a repository refactoring, I have to improve its flexibility and reduce the count of method.

Where are the following methods:

  Archive GetAllUsersByRole (Role Role) Users GetUserByuserName (String Username)  

... The only way to get a link intent is to:

  Icon Gateusors (Expression E) {// Recover User Collection from Collection // Apply expression to archive and return}  < / Pre> 

Is this a proper approach? Probably I have to face some of the skills because the collection of full users will need to be retrieved and filtered all the time rather than getting a subset of users according to every hard-coded criteria?

EDIT: NHibernate provides ORM to my implementation.

You really want to take an expression as the argument of that method.

As a demonstration, it is true how far you want to go with it. The simplest method is bringing all the objects in memory and then filtering with the ingenious expression. On the other hand, you mention some types of criteria. I do not know what your previous data system is, but you can take these passed filters and change them to your criteria. This is essentially for SQL and Linq entities from Linq, but hopefully the limitations of the boundaries you need to support are quite small. If not, you want to take this approach, then switching to one of the ORM tools can mean.


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -