DataSetのためにLinqで左結合を使用すると、エラー "値はnullではありません。パラメータ名の行"になります。Linqの左結合と他の結合の変数の使用
以下は、データとlinqクエリです。
- DataRowCollection - アイテム(列 - ITEM_ID、SKU、数量)
- DataRowCollection - キャンペーン(カラム - ITEM_ID、Promotion_Id)
- DataRowCollection - 成分(カラム - COMPONENT_ID、Promotion_id)
- DataRowCollection - amount(Columns - Component_id、Amount_Text、currency)
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")
};
-
コードをせずに働いていた任意の割引
を持っていないアイテムの割引
すべてのアイテムに割引があったときに左外部結合を残しましたが、いずれのアイテムにも割引がない場合は、そのアイテムをスキップして、左外部結合を使用しなければなりませんでした。
ご協力いただきまして誠にありがとうございます。明確化が必要な場合はお知らせください。
ありがとうございます。
これは試しましたが、同じエラー "値はnullにはできません。パラメータ名:行" –