var val1 =
(from main in
(from irac in objIRAC
join iip in objIIP on irac.InvoiceItemID equals iip.InvoiceItemID
join oritc in
(from ritc in objRITC
join iips in objIIP on ritc.InvoiceItemPremiumID equals iips.InvoiceItemPremiumID
where ritc.ReconID == ReconId
&& ritc.BookOfBusinessInvoiceItemPremiumID == BookOfBusinessInvoiceItemPremiumID
&& ritc.InvoiceID == InvoiceId
group new { ritc, iips } by new { ritc.ReconID, iips.InvoiceItemID }
into ritcs
select new
{
ritcs.Key.ReconID,
ritcs.Key.InvoiceItemID
}) on ReconId equals oritc.ReconID into oritcs // ReconId
from oritc in oritcs.DefaultIfEmpty()
where iip.InvoiceItemPremiumID == BookOfBusinessInvoiceItemPremiumID
select new
{
oritc.InvoiceItemID,
irac.CommissionOnTypeID,
irac.BOBFamilyID,
irac.RateTypeID,
irac.Rate,
irac.CommissionAdjustmentFlag
})
join sub in objIRAC // Here getting the error
on new { main.InvoiceItemID, main.CommissionOnTypeID, main.BOBFamilyID, main.RateTypeID, main.Rate, main.CommissionAdjustmentFlag }
equals new { sub.InvoiceItemID, sub.CommissionOnTypeID, sub.BOBFamilyID, sub.RateTypeID, sub.Rate, sub.CommissionAdjustmentFlag }
into subs
from osub in subs.DefaultIfEmpty()
select new { osub.InvoiceItemID });
问问题
897 次
2 回答
0
检查类型
main.InvoiceItemID, main.CommissionOnTypeID, main.BOBFamilyID, main.RateTypeID, main.Rate, main.CommissionAdjustmentFlag
和
sub.InvoiceItemID, sub.CommissionOnTypeID, sub.BOBFamilyID, sub.RateTypeID, sub.Rate, sub.CommissionAdjustmentFlag
它们应该完全匹配。即:如果一个属性是 aNullable<int>
而对应的属性是int
它不匹配。由于所有属性但InvoiceItemID
都来自同一个实体 InvoiceItemID 可能是罪魁祸首。
于 2012-07-26T15:29:28.677 回答
0
赔率是您的外键引用之一是可以为空的,您需要进行显式转换才能使联接(假定内部联接)起作用。
var result =
from a in context.T1
join b in context.T2
on new { s.Field1, s.Field2 }
equals new {
Field1 = (int)b.T3.Field1 /* Join via sub-table, explicit conversion from int? to int */
,Field2 = (int)b.Field2 /* explicit conversion from int? to int */
}
where
b.T3.Field1 != null /* Specify no nulls allowed for inner-join fields */
&& b.Field2 != null
&& b.Field3 == InputVar1 /* Input Search Variables */
&& b.Field4 == InputVar2
select a;
上面的示例是从我正在使用的实际查询中重命名的。
于 2013-06-25T16:57:23.140 回答