R
Ramkrishnan .
hi,
i got an error "A lambda expression with a statement body cannot be
converted to an expression tree" when i write below code.
data = is the iquerable object.
how to solve tis error.
data.Where(
item =>
{
object oValue =
item.GetType().GetProperty(field).GetValue(item, null);
IComparable cItem = oValue as IComparable;
switch (comparison)
{
case Comparison.Eq:
switch (type)
{
case FilterType.List:
return !(value as
System.Collections.ObjectModel.ReadOnlyCollection<string>).Contains(oValue.ToString());
case FilterType.String:
return !
oValue.ToString().StartsWith(value.ToString());
default:
return !
cItem.Equals(value);
}
case Comparison.Gt:
return cItem.CompareTo(value) < 1;
case Comparison.Lt:
return cItem.CompareTo(value) >
-1;
default:
throw new
ArgumentOutOfRangeException();
}
}
);
i got an error "A lambda expression with a statement body cannot be
converted to an expression tree" when i write below code.
data = is the iquerable object.
how to solve tis error.
data.Where(
item =>
{
object oValue =
item.GetType().GetProperty(field).GetValue(item, null);
IComparable cItem = oValue as IComparable;
switch (comparison)
{
case Comparison.Eq:
switch (type)
{
case FilterType.List:
return !(value as
System.Collections.ObjectModel.ReadOnlyCollection<string>).Contains(oValue.ToString());
case FilterType.String:
return !
oValue.ToString().StartsWith(value.ToString());
default:
return !
cItem.Equals(value);
}
case Comparison.Gt:
return cItem.CompareTo(value) < 1;
case Comparison.Lt:
return cItem.CompareTo(value) >
-1;
default:
throw new
ArgumentOutOfRangeException();
}
}
);