0
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?
我檢查了我的數據庫,但我不知道它總是null.Expression樹和Lambda表達式可能是問題。爲什麼在調用方法IQueryable.FirstOrDefault()時總是返回null?
我確定它是引用類型。 – user1439889