我正在尝试使用linq作为列表获取税号、税号和税率。但是它显示了以下错误:"DbExpressionBinding需要一个带有集合ResultType的输入表达式。
表数据
代号_名称_
1个Tax1 4
1税务1.2 7
2个Tax2 5
3 Tax3 2
需要输出
代号_名称_
2个Tax2 5
3 Tax3 2
条件:如果代码数为一个,则检索详细信息。
UAAPPEntities context;
context=new UAAPPEntities();
var x = from txs in context.OTAXs
where txs.Code.Count()<=1
select new TaxModel{ taxCode=txs.Code, taxName=txs.Name,taxRate=txs.Rate.Value };
taxList = x.ToList();
return taxList;发布于 2014-10-07 13:25:08
使用以下查询获得解决方案:
var x = from t1 in context.OTAXs
group t1.Code by new { t1.Code } into g
where g.Count()<=1
join txs in context.OTAXs on g.Key.Code equals txs.Code
select new TaxModel { taxCode = txs.Code, taxName = txs.Code, description = txs.Code, taxRate = txs.Rate.Value }; 快乐编码..。
谢谢英杜。
https://stackoverflow.com/questions/26233358
复制相似问题