public class CellValue
{
double? Max;
double? Min;
string Value;
string Annotation;
}
public T GetOne(Expression<Func<T, bool>> predicate)
{
IQueryable<T> query = this.context.Set<T>();
return query.FirstOrDefault(predicate);
}
public class Steel: CellValue{}
CellValue cell = new CellValue{Max = 0.8, Min = 0.1, Value="test"};
Steel steel = service.GetOne(t=>t.Max == cell.Max && t.Min == cell.Min && t.Value ==cell.Value && t.Annotation == cell.Annotation);
//but the object steel is always null. Jush Why?
我检查了我的数据库,但我不知道它总是为空。表达式树和 Lambda 表达式可能是问题所在。