Permalink
Browse files

Refactoring (Fix NH-2022)

SVN: branches/2.1.x@4852
  • Loading branch information...
1 parent 87307cf commit f7f95a0eaff69c68dbe6f43135982db4a6683092 @fabiomaulo fabiomaulo committed Nov 22, 2009
Showing with 16 additions and 15 deletions.
  1. +16 −15 src/NHibernate/Criterion/Example.cs
View
31 src/NHibernate/Criterion/Example.cs
@@ -57,9 +57,9 @@ public interface IPropertySelector
}
//private static readonly IPropertySelector NotNull = new NotNullPropertySelector();
- private static readonly IPropertySelector NotNullOrEmptyString = new NotNullOrEmptyStringPropertySelector();
- private static readonly IPropertySelector All = new AllPropertySelector();
- private static readonly IPropertySelector NotNullOrZero = new NotNullOrZeroPropertySelector();
+ protected static readonly IPropertySelector NotNullOrEmptyString = new NotNullOrEmptyStringPropertySelector();
+ protected static readonly IPropertySelector All = new AllPropertySelector();
+ protected static readonly IPropertySelector NotNullOrZero = new NotNullOrZeroPropertySelector();
/// <summary>
/// Implementation of <see cref="IPropertySelector"/> that includes all
@@ -476,21 +476,22 @@ protected void AddComponentTypedValues(string path, object component, IAbstractC
builder.Add(" and ");
}
- ICriterion crit;
- if (propertyValue != null)
- {
- bool isString = propertyValue is String;
- crit = (_isLikeEnabled && isString) ?
- (ICriterion) new LikeExpression(propertyName, propertyValue.ToString(), _matchMode, escapeCharacter, _isIgnoreCaseEnabled) :
- new SimpleExpression(propertyName, propertyValue, " = ", _isIgnoreCaseEnabled && isString);
- }
- else
- {
- crit = new NullExpression(propertyName);
- }
+ ICriterion crit = propertyValue != null
+ ? GetNotNullPropertyCriterion(propertyValue, propertyName)
+ : new NullExpression(propertyName);
builder.Add(crit.ToSqlString(criteria, cq, enabledFilters));
}
+ protected virtual ICriterion GetNotNullPropertyCriterion(object propertyValue, string propertyName)
+ {
+ bool isString = propertyValue is string;
+ return (_isLikeEnabled && isString)
+ ? (ICriterion)
+ new LikeExpression(propertyName, propertyValue.ToString(), _matchMode, escapeCharacter,
+ _isIgnoreCaseEnabled)
+ : new SimpleExpression(propertyName, propertyValue, " = ", _isIgnoreCaseEnabled && isString);
+ }
+
protected void AppendComponentCondition(
String path,
object component,

0 comments on commit f7f95a0

Please sign in to comment.