当我使用Linq中的左连接为DataSet时,我卡住的错误“值不能为空参数名称行”。左连接Linq并使用变量为其他连接
以下是数据和linq查询。
- DataRowCollection - 项目(列 - ITEM_ID,SKU,数量)
- DataRowCollection - 优惠(色谱柱 - ITEM_ID,Promotion_Id)
- DataRowCollection - 组分(色谱柱 - COMPONENT_ID,Promotion_id)
- DataRowCollection - 金额(列 - Component_id,Amount_Text,货币)
var q =
from Item in items
join promotion in promotions
on Item.Field<int>("Item_id") equals promotion.Field<int?>("Item_id") into promo
from promotion in promo.DefaultIfEmpty()
join disccomponent in components
on promotion.Field<int>("Promotion_Id") equals disccomponent.Field<int?>("Promotion_Id")
join discamounts in amounts
on disccomponent.Field<int>("Component_id") equals discamounts.Field<int?>("Component_id")
where disccomponent.Field<string>("Type") == "Principal"
select new
{
SKU = Item.Field<string>("SKU"),
Quantity = Item.Field<string>("Quantity"),
DiscountAmount = discamounts.Field<string>("Amount_Text"),
DiscountCurrency = discamounts.Field<string>("currency")
};
我需要得到以下几点:
- SKU,数量和折扣的细节对于具有打折商品
- SKU,数量为不具有任何折扣
代码工作没有项目当所有物品都有折扣时左外连接,但如果任何物品没有任何折扣,则跳过该物品,因此我不得不使用左外连接。
任何帮助,高度赞赏。请让我知道是否需要澄清。
在此先感谢。
试过这个,但仍然是相同的错误“值不能为空参数名称:行” –