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. LINQ
  4. Need to Convert This to LINQ

Need to Convert This to LINQ

Scheduled Pinned Locked Moved LINQ
databasecsharplinqsysadmin
5 Posts 3 Posters 2 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.
  • D Offline
    D Offline
    dotnetme2
    wrote on last edited by
    #1

    New to LINQ - I have an application that accesses the DB over a VPN and sometimes the with a slow connection I have a SQL statement that runs as one statement to the server and back... don't want to go back and fourth. I can do simple LINQ statements and I want to convert it to LINQ but need to keep as one statement and having trouble...

    if exists (select * from MLEntries where UniversalID = sUID)
    Select ml.UniversalID, sEmailaddr as Email, ml.CLID, ml.CN,c.Company,p.First_name, P.Last_name,
    a.Address_Line_1 , a.Address_Line_2, a.City, a.State_Province, a.Country, a.Zip_Code, a.Phone_1
    from MLEntries ml
    inner join people p on p.CLID = ml.CLID and p.CN = ml.CN
    inner join address a on p.CLID = a.CLID and p.address_id = a.CN
    inner join Client c on c.CLID = p.CLID and c.CN = 0
    where ml.UniversalID = sUID
    else
    Select '' as UniversalID, sEmailaddr as Email, uf.CLID, uf.CN,c.Company,p.First_name, P.Last_name,
    a.Address_Line_1 , a.Address_Line_2, a.City, a.State_Province, a.Country, a.Zip_Code, a.Phone_1
    from UF_tbl uf
    inner join people p on p.CLID = uf.CLID and p.CN = uf.CN
    inner join address a on p.CLID = a.CLID and p.address_id = a.CN
    inner join Client c on c.CLID = p.CLID and c.CN = 0
    where Email_Addr = sEmailAddr

    Thanks for any help dotnetme :confused:

    dotnetme2

    D 1 Reply Last reply
    0
    • D dotnetme2

      New to LINQ - I have an application that accesses the DB over a VPN and sometimes the with a slow connection I have a SQL statement that runs as one statement to the server and back... don't want to go back and fourth. I can do simple LINQ statements and I want to convert it to LINQ but need to keep as one statement and having trouble...

      if exists (select * from MLEntries where UniversalID = sUID)
      Select ml.UniversalID, sEmailaddr as Email, ml.CLID, ml.CN,c.Company,p.First_name, P.Last_name,
      a.Address_Line_1 , a.Address_Line_2, a.City, a.State_Province, a.Country, a.Zip_Code, a.Phone_1
      from MLEntries ml
      inner join people p on p.CLID = ml.CLID and p.CN = ml.CN
      inner join address a on p.CLID = a.CLID and p.address_id = a.CN
      inner join Client c on c.CLID = p.CLID and c.CN = 0
      where ml.UniversalID = sUID
      else
      Select '' as UniversalID, sEmailaddr as Email, uf.CLID, uf.CN,c.Company,p.First_name, P.Last_name,
      a.Address_Line_1 , a.Address_Line_2, a.City, a.State_Province, a.Country, a.Zip_Code, a.Phone_1
      from UF_tbl uf
      inner join people p on p.CLID = uf.CLID and p.CN = uf.CN
      inner join address a on p.CLID = a.CLID and p.address_id = a.CN
      inner join Client c on c.CLID = p.CLID and c.CN = 0
      where Email_Addr = sEmailAddr

      Thanks for any help dotnetme :confused:

      dotnetme2

      D Offline
      D Offline
      dan sh
      wrote on last edited by
      #2

      What have you tried so far? Check this[^] link. Might help.

      N D 2 Replies Last reply
      0
      • D dan sh

        What have you tried so far? Check this[^] link. Might help.

        N Offline
        N Offline
        Not Active
        wrote on last edited by
        #3

        Nice resource, definitely adding it the bookmarks


        I know the language. I've read a book. - _Madmatt

        D 1 Reply Last reply
        0
        • N Not Active

          Nice resource, definitely adding it the bookmarks


          I know the language. I've read a book. - _Madmatt

          D Offline
          D Offline
          dan sh
          wrote on last edited by
          #4

          I guess I have posted it quite a few times here. It is something that I always check first when stuck with LINQ.

          1 Reply Last reply
          0
          • D dan sh

            What have you tried so far? Check this[^] link. Might help.

            D Offline
            D Offline
            dotnetme2
            wrote on last edited by
            #5

            Hi thanks... I'm using VB... Found similar link to yours... As I said I'm new to LINQ so not sure if I'm approaching it the right way, but I thought would try and break it down into parts first... I tried serveral ways but here is one part I was trying to do. turning this SQL Statment

            Select '' as UniversalID, sEmailaddr as Email, uf.CLID, uf.CN,c.Company,p.First_name, P.Last_name,
            a.Address_Line_1 , a.Address_Line_2, a.City, a.State_Province, a.Country, a.Zip_Code, a.Phone_1
            from UF_tbl uf
            inner join people p on p.CLID = uf.CLID and p.CN = uf.CN
            inner join address a on p.CLID = a.CLID and p.address_id = a.CN
            inner join Client c on c.CLID = p.CLID and c.CN = 0
            where Email_Addr = sEmailAddr

            into this LINQ

            Dim AllPeople = From uf In BDDB.User_Fields _
            Group Join p In BDDB.Peoples On p.CLID Equals uf.CLID And p.CN Equals uf.CN Into pInfo = Group _
            Group Join a In BDDB.Addresses On a.CLID Equals 'got stuck trying to join a to p???

            Or this LINQ

            Dim Contact = From p In BDDB.Peoples _
            Group Join uf In BDDB.User_Fields On uf.CLID Equals p.CLID And uf.CN Equals p.CN Into ufInfo = Group _
            Group Join a In BDDB.Addresses On a.CLID Equals p.CLID And a.CN Equals p.Address_Id Into addrInfo = Group _
            Group Join c In BDDB.Clients On c.CLID Equals p.CLID And c.CN Equals 0 Into CoInfo = Group _
            Where 'uf.email_addr = sEmailAddr???

            Ok so they group into an alias but in the "Where" statement I can't get to the "uf" table anymore??? hmmm that's where they really lost me! Thanks for your Help...

            dotnetme2

            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