Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. LINQ : Unmatched data is coming for inner join

LINQ : Unmatched data is coming for inner join

Scheduled Pinned Locked Moved C#
csharpdatabaselinqregexhelp
9 Posts 3 Posters 5 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mou_kol
    wrote on last edited by
    #1

    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

    L Richard DeemingR 2 Replies Last reply
    0
    • M Mou_kol

      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

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      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.

      M 1 Reply Last reply
      0
      • L Lost User

        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.

        M Offline
        M Offline
        Mou_kol
        wrote on last edited by
        #3

        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

        L 1 Reply Last reply
        0
        • M Mou_kol

          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

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          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.

          M 1 Reply Last reply
          0
          • L Lost User

            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.

            M Offline
            M Offline
            Mou_kol
            wrote on last edited by
            #5

            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.

            L 1 Reply Last reply
            0
            • M Mou_kol

              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

              Richard DeemingR Offline
              Richard DeemingR Offline
              Richard Deeming
              wrote on last edited by
              #6

              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

              "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

              M 1 Reply Last reply
              0
              • M Mou_kol

                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.

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                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.

                M 1 Reply Last reply
                0
                • L Lost User

                  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.

                  M Offline
                  M Offline
                  Mou_kol
                  wrote on last edited by
                  #8

                  the problem was solved. problem was in data which causing the issue. thanks for reply and time. have nice time ahead sir.

                  1 Reply Last reply
                  0
                  • Richard DeemingR Richard Deeming

                    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

                    M Offline
                    M Offline
                    Mou_kol
                    wrote on last edited by
                    #9

                    the problem was solved. problem was in data which causing the issue. thanks for reply and time. have nice time ahead sir.

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups