Hi,
I am trying use an iPredicate to compare a value to a column in a case-independent way. I got this idea from another thread here in the forum:
public static IPredicate iCaseEquals(EntityField2 field, string value)
{
if (!string.IsNullOrEmpty(value))
{
value = value.ToUpper();
}
IExpression upperFunc = new DbFunctionCall("UPPER", new object[] { field });
EntityField upperField = new EntityField("upper", upperFunc);
IPredicate predicate = (upperField == value);
return predicate;
}
Everything compiles fine, but then I run into a NullReferenceException ("Object reference not set to an instance of an object.") when using fetching the entity collection in here:
// create a filter for the unique look up constraint
IRelationPredicateBucket filter = new RelationPredicateBucket();
filter.PredicateExpression.Add(iCaseEquals(CityFields.Name, name));
EntityCollection<CityEntity> results = new EntityCollection<CityEntity>();
adapter.FetchEntityCollection(results, filter);
I would be more than happy for some hints.
I am working with LGP 2.6, MSSQL 2005, and .NET.