How to do left and inner join in same query

  • Thread starter Thread starter Sudip_inn
  • Start date Start date
S

Sudip_inn

Guest
var query = (from r1 in dtMappedSectionNotEmpty.AsEnumerable()
join r2 in dtData.AsEnumerable()
on r1.Field<string>("Row").Trim().ToUpper() equals r2.Field<string>("RowCoordinate").Trim().ToUpper()
join r3 in _Periods.AsEnumerable()
on r2.Field<string>("StandardDate").Replace("A", string.Empty).Replace("E", string.Empty).Trim().ToUpper() equals r3.Replace("A", string.Empty).Replace("E", string.Empty).Trim().ToUpper()
where r1.Field<string>("Tab").Trim().ToUpper() == strTab.Trim().ToUpper()
select new BrokerData
{
RowNumber = r1.Field<string>("Row") ?? "0",
TabName = r1.Field<string>("Matched Section") ?? "",
StandardDate = r3.ToString(),
BRTab = r1.Field<string>("Tab") ?? "",
BRLineItem = r1.Field<string>("Broker Items") ?? "",
Action = r1.Field<string>("Action") ?? "",
StandardLineItem = r1.Field<string>("Matched Items") ?? "",
StandardValue = ProcessValue(r2.Field<string>("LineItemDateValue") ?? "", r1.Field<string>("Units") ?? "", false, r1.Field<string>("Tab") ?? "", r1.Field<string>("Broker Items") ?? "", r1.Field<string>("Row") ?? "0",
r1.Field<string>("Matched Section") ?? "", r1.Field<string>("Matched Items") ?? "", r2.Field<string>("StandardDate").ToString().Replace("A", string.Empty).Replace("E", string.Empty) ?? ""),
Link = (r1.Field<string>("Link") == null ? false : r1.Field<string>("Link").ToString().ToUpper() == "TRUE" ? true : false),
LinkedItemList = (r1.Field<string>("LinkedItemList") == null ? "" : r1.Field<string>("LinkedItemList").ToString()),
Cumulative = (r1.Field<string>("cumulative") == null ? false : r1.Field<string>("cumulative").ToString().ToUpper() == "TRUE" ? true : false)
}).ToList();


in my above code there are 2 datatable and one list. now i am not being able to compose left and inner join in same query.

there will be left join between dtMappedSectionNotEmpty and dtData. there will be left join between r1 & r2

again there will be inner join between dtData & _Periods means i want inner join between r2 & r3

so please see my code and give me another set same LINQ code where left join and inner join will be there. thanks

Continue reading...
 
Back
Top