LINQ : Unmatched data is coming for inner join
-
I am joining two list List. i am joining 4 fields based on section,xfundcode,period & broker ** **cfList & QCViewAllBrokerList1 they are two List type. Records exist in cfList for the section -> CONSENSUS MODEL, xfundcode -> RD_001, period -> 2018 FY & broker -> BW but there is no records exist in this list QCViewAllBrokerList1 for the section -> CONSENSUS MODEL, xfundcode -> RD_001, period -> 2018 FY & broker -> BW. so when i am doing inner join then match not found because same data does not exist in two list. as a result there no records should be stored in result variable called 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 after inner join done. How it is possible ? how data is storing in final result set called QCViewAllHistValue1 for the section -> CONSENSUS MODEL, xfundcode -> RD_001, period -> 2018 FY & broker -> BW This is causing problem in my case.
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();Please guide me where i am making the mistake in my above linq query. thanks
-
I am joining two list List. i am joining 4 fields based on section,xfundcode,period & broker ** **cfList & QCViewAllBrokerList1 they are two List type. Records exist in cfList for the section -> CONSENSUS MODEL, xfundcode -> RD_001, period -> 2018 FY & broker -> BW but there is no records exist in this list QCViewAllBrokerList1 for the section -> CONSENSUS MODEL, xfundcode -> RD_001, period -> 2018 FY & broker -> BW. so when i am doing inner join then match not found because same data does not exist in two list. as a result there no records should be stored in result variable called 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 after inner join done. How it is possible ? how data is storing in final result set called QCViewAllHistValue1 for the section -> CONSENSUS MODEL, xfundcode -> RD_001, period -> 2018 FY & broker -> BW This is causing problem in my case.
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();Please guide me where i am making the mistake in my above linq query. thanks
What happens if you do a real join using SQL? Also, normalize on entering/saving data, not on each query :thumbsup:
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
-
What happens if you do a real join using SQL? Also, normalize on entering/saving data, not on each query :thumbsup:
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
-
i am not using SQL or database. my data is in xml file and i am reading those xml file by dataset and populate List and doing inner join between two list
You can execute SQL on an XML dataset too; the point I'm making is that you can check that way whether it is something in the code/LINQ, or whether SQL shows the same result (meaning it may be due to the data, not the code).
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
-
You can execute SQL on an XML dataset too; the point I'm making is that you can check that way whether it is something in the code/LINQ, or whether SQL shows the same result (meaning it may be due to the data, not the code).
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
-
I am joining two list List. i am joining 4 fields based on section,xfundcode,period & broker ** **cfList & QCViewAllBrokerList1 they are two List type. Records exist in cfList for the section -> CONSENSUS MODEL, xfundcode -> RD_001, period -> 2018 FY & broker -> BW but there is no records exist in this list QCViewAllBrokerList1 for the section -> CONSENSUS MODEL, xfundcode -> RD_001, period -> 2018 FY & broker -> BW. so when i am doing inner join then match not found because same data does not exist in two list. as a result there no records should be stored in result variable called 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 after inner join done. How it is possible ? how data is storing in final result set called QCViewAllHistValue1 for the section -> CONSENSUS MODEL, xfundcode -> RD_001, period -> 2018 FY & broker -> BW This is causing problem in my case.
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();Please guide me where i am making the mistake in my above linq query. thanks
You need to show us some sample data. If possible, create a simple .NET Fiddle[^] to demonstrate the problem, and post the link here. NB: Make sure to remove any irrelevant or confidential data before posting. :)
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
i am not using sir Entity framework. i am using LINQ to object. i think when we use LINQ to object then we can't use sql on xml data. i store my xml data in LIST and later query those list by LINQ. hopefully i am clear what i am doing.
Mou_kol wrote:
i am not using sir Entity framework. i am using LINQ to object.
Doesn't matter; you can even try the query in MS Access.
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
-
Mou_kol wrote:
i am not using sir Entity framework. i am using LINQ to object.
Doesn't matter; you can even try the query in MS Access.
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
-
You need to show us some sample data. If possible, create a simple .NET Fiddle[^] to demonstrate the problem, and post the link here. NB: Make sure to remove any irrelevant or confidential data before posting. :)
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer