Is there someone who can please explain why the following is not working??:
the model is defined like this (very simple version)
public class Monument
{
[Key]
public int? MonumentId { get; set; }
public string Name { get; set; }
}
The Find method in my repository implementation is defined like this:
public virtual IQueryable<T> Find(Expression<Func<T, bool>> where)
{
return _dbset.Where(where);
}
The where parameter gets a value this way:
whereClause = c => ( (FilteringRecord.MonumentId <= 0 ?
true : c.MonumentId == FilteringRecord.MonumentId)
&& (String.IsNullOrEmpty(FilteringRecord.Name) ?
true :c.Name.Contains(FilteringRecord.Name)) );
So if the value of FilteringRecord.MonumentId is equal to a number i get the desired record, but if the FilteringRecord.Name has a value it’s completely ignored!! Why???
The same works fine on the first version of Entity Framework or LINQ to SQL!!
Thanks in advance!!
Turns out that the expression is working as expected! The error was caused by a wrong binding in the UI (this is a WPF application), giving wrong values to FilteringRecord!