-2
领域是否有LINQ乘两个Linq中
为乘两个字段的任何选项public class details
{
public int qty { get; set; }
public decimal unitprice{ get; set; }
public decimal total{ get; set; }
}
select new details
{
qty =x.qty ,
unitprice= x.unitprice,
total= x.qty*x.unitprice,
}
如果不是请放弃任何合适的代码
你做的唯一正确的。有什么问题? –
乘数前检查空值或0值。如** total =(x.qty!= 0?x.qty:1)*(x.unitprice!= 0?x.unitprice:1)** –