public static decimal getall(decimal number) {
decimal sigma = (from Sigma_Table in db.Sigma_Tables
where Sigma_Table.Defect_Rate < number
select (decimal)Sigma_Table.Sigma_Value).Min();
return sigma;
}
Defect_Rate
&lt;应该满足number
条件,并且我希望Sigma_Value
的最小值。
答案 0 :(得分:0)
只需为您的案例使用扩展方法语法:
public static decimal GetAll(decimal number)
{
return db.Sigma_Tables.Where(x => x.Defect_Rate < number)
.Select(x => (decimal)x.Sigma_Value)
.DefaultIfEmpty() // we need it, if null selected
.Min();
}