-
-
Save carcer/1564876 to your computer and use it in GitHub Desktop.
nh headache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static ICriterion BuildCriteria(params MatchableClientParams[] clientParams) | |
{ | |
var result = Restrictions.Disjunction(); | |
foreach (var parameters in clientParams) | |
{ | |
var parameters1 = parameters; | |
var criteria = parameters1.BuildCriteria(); | |
result.Add(criteria); | |
} | |
return result; | |
} | |
internal class MatchableClientParams | |
{ | |
// doing it this way sorts the responsibilities a little and adds a little more extensibility. Because the MatchableClientParams is responsible for creating the ICriterion, you can subclass it to change behaviours without modifying any other code | |
public ICriterion BuildCriteria() | |
{ | |
return Expression.Sql(string.Format("'{0}' like '%' + {1} + '%'", "SomeTextWithLastNameIn", "Name"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment