LINQ : Unmatch data is coming for innser join

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

Sudip_inn

Guest
This is my query when i am joining two list.

i am doing joining based on section, xfundcode , period & broker

there is no records exist in this list QCViewAllBrokerList1 for the section CONSENSUS MODEL, xfundcode RD_001, period 2018 FY & broker BW.

but records exist in cfList for the section CONSENSUS MODEL, xfundcode RD_001, period 2018 FY & broker BW.

so when i am doing inner join then match found because same data does not exist in two list. as a result there should be no records exist in list of QCViewAllHistValue1 for the section CONSENSUS MODEL, xfundcode RD_001, period 2018 FY & broker BW. but the problem is records exist in the list of QCViewAllHistValue1 for the section CONSENSUS MODEL, xfundcode RD_001, period 2018 FY & broker BW.

why it is happening? what mistake i made in my below LINQ inner join code ?

var QCViewAllHistValue1 = (from frmlst in cfList
join viewalllst in QCViewAllBrokerList1
on new
{
val = String.IsNullOrEmpty(frmlst.Section) ? "" : frmlst.Section.Trim().ToUpper(),
val1 = String.IsNullOrEmpty(frmlst.xFundCode) ? "" : frmlst.xFundCode.Trim().ToUpper(),
val2 = String.IsNullOrEmpty(frmlst.Period) ? "" : frmlst.Period.Replace("A", "").Replace("E", "").Trim().ToUpper(),
val3 = String.IsNullOrEmpty(frmlst.Broker) ? "" : frmlst.Broker.Trim().ToUpper()
}
equals new
{
val = String.IsNullOrEmpty(viewalllst.ViewAllSection) ? "" : viewalllst.ViewAllSection.Trim().ToUpper(),
val1 = String.IsNullOrEmpty(viewalllst.xFundCode) ? "" : viewalllst.xFundCode.Trim().ToUpper(),
val2 = String.IsNullOrEmpty(viewalllst.ViewAllPeriod) ? "" : viewalllst.ViewAllPeriod.Replace("A", "").Replace("E", "").Trim().ToUpper(),
val3 = String.IsNullOrEmpty(viewalllst.ViewAllBroker) ? "" : viewalllst.ViewAllBroker.Trim().ToUpper()
}

select new QCHelper()
{
Value = viewalllst == null ? string.Empty : (viewalllst.Value == null ? string.Empty : viewalllst.Value),
}).ToList<QCHelper>();


if i hard code value in JOIN then no data is coming. see the LINQ join with hard code value for join area.

in this case no data is coming for CONSENSUS MODEL, xfundcode RD_001, period 2018 FY & broker BW. and it is right

var QCViewAllHistValue1 = (from frmlst in cfList
join viewalllst in QCViewAllBrokerList1
on new
{
val = "CONSENSUS MODEL",
val1 = "DEPAM",
val2 = "2018 FY",
val3 = "BW"
}
equals new
{
val = "CONSENSUS MODEL",
val1 = "RD_001",
val2 = "2018 FY",
val3 = "BW"
}

select new QCHelper()
{
Value = viewalllst == null ? string.Empty : (viewalllst.Value == null ? string.Empty : viewalllst.Value),
}).ToList<QCHelper>();

so issue is why value is coming after join when second join list has no data for CONSENSUS MODEL, xfundcode RD_001, period 2018 FY & broker BW
Please help me. thanks

Continue reading...
 
Back
Top