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. linq join statement help reqd

linq join statement help reqd

Scheduled Pinned Locked Moved LINQ
csharpdatabaselinqhelpquestion
6 Posts 4 Posters 0 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.
  • H Offline
    H Offline
    haseeb_saeed
    wrote on last edited by
    #1

    I am trying to do a join using linq. i have 2 tables oempart and parttypes. i want to carry out join in linq and select only rows where oempart.id=5; my sql select statement is : (sql statement works fine) Select oemparts.name,parttypes.id,parttypes.product_type from oemparts join parttypes on oemparts.parttype_id=parttypes.id where parttypes.id =5 i want to do same with linq. i tried alot but can't do it. Please help... Question 2: Also this application has been developed partly by other programmer who had very good idea of linq. As i see, his sql to linq file (dbml) has a lot of coding... eg [table(name="dbo.oemparts")] and then 100 lines of code, similar case for associations etc... I want to know if such code is hardcoded or is produced by vs2008. i tried making linq to sql file from scratch but didn't have this code... is there any designer way of doin it or is it hard coding... Thanx

    haseeb

    R V S 3 Replies Last reply
    0
    • H haseeb_saeed

      I am trying to do a join using linq. i have 2 tables oempart and parttypes. i want to carry out join in linq and select only rows where oempart.id=5; my sql select statement is : (sql statement works fine) Select oemparts.name,parttypes.id,parttypes.product_type from oemparts join parttypes on oemparts.parttype_id=parttypes.id where parttypes.id =5 i want to do same with linq. i tried alot but can't do it. Please help... Question 2: Also this application has been developed partly by other programmer who had very good idea of linq. As i see, his sql to linq file (dbml) has a lot of coding... eg [table(name="dbo.oemparts")] and then 100 lines of code, similar case for associations etc... I want to know if such code is hardcoded or is produced by vs2008. i tried making linq to sql file from scratch but didn't have this code... is there any designer way of doin it or is it hard coding... Thanx

      haseeb

      R Offline
      R Offline
      Rolando CC
      wrote on last edited by
      #2

      Hi, some resources about joins: http://www.onedotnetway.com/linq-to-sql-join-on-multiple-conditions/[^] http://www.hookedonlinq.com/LINQtoSQL5MinuteOverview.ashx[^] All that coding you see is generated by linq to sql designer when you add new entities.

      H 1 Reply Last reply
      0
      • R Rolando CC

        Hi, some resources about joins: http://www.onedotnetway.com/linq-to-sql-join-on-multiple-conditions/[^] http://www.hookedonlinq.com/LINQtoSQL5MinuteOverview.ashx[^] All that coding you see is generated by linq to sql designer when you add new entities.

        H Offline
        H Offline
        haseeb_saeed
        wrote on last edited by
        #3

        Thanx... I am sorry that i am asking alot of questions. actually, i am assigned a project in the middle. Original person has left and hasn't left any piece of documentation. He has used linq extensively in 2 forms with incomplete functionality and i want to learn linq . Already, i am doin alot of searching and learning on linq but as i mentioned, in dbml file, there is alot of code (designtime generated) and i want to learn doing this.. .i made a new linqto sql class, added tables by dragging them , some code is generated but entities are not generated. how do i generate these entities... Thanks for ur replies. They all have been very useful. also in links that you have forwarded , linq syntax used is var a = from b in db.TableName do something... i have tried this...it doesn't work, when i try like var a = from b in db.gettable do something... it works... what's the concept behind this... Thankyou for helping

        haseeb

        R 1 Reply Last reply
        0
        • H haseeb_saeed

          Thanx... I am sorry that i am asking alot of questions. actually, i am assigned a project in the middle. Original person has left and hasn't left any piece of documentation. He has used linq extensively in 2 forms with incomplete functionality and i want to learn linq . Already, i am doin alot of searching and learning on linq but as i mentioned, in dbml file, there is alot of code (designtime generated) and i want to learn doing this.. .i made a new linqto sql class, added tables by dragging them , some code is generated but entities are not generated. how do i generate these entities... Thanks for ur replies. They all have been very useful. also in links that you have forwarded , linq syntax used is var a = from b in db.TableName do something... i have tried this...it doesn't work, when i try like var a = from b in db.gettable do something... it works... what's the concept behind this... Thankyou for helping

          haseeb

          R Offline
          R Offline
          Rolando CC
          wrote on last edited by
          #4

          var a = from b in db.TableName first, you have the databasecontext (db) in this example, inside db are the entities you have drag and drop from your database. With that line of code you are basically doing: select * from tableName but without write any sql code neither using datasets or similar... check the other developers sintax, post an example here...

          1 Reply Last reply
          0
          • H haseeb_saeed

            I am trying to do a join using linq. i have 2 tables oempart and parttypes. i want to carry out join in linq and select only rows where oempart.id=5; my sql select statement is : (sql statement works fine) Select oemparts.name,parttypes.id,parttypes.product_type from oemparts join parttypes on oemparts.parttype_id=parttypes.id where parttypes.id =5 i want to do same with linq. i tried alot but can't do it. Please help... Question 2: Also this application has been developed partly by other programmer who had very good idea of linq. As i see, his sql to linq file (dbml) has a lot of coding... eg [table(name="dbo.oemparts")] and then 100 lines of code, similar case for associations etc... I want to know if such code is hardcoded or is produced by vs2008. i tried making linq to sql file from scratch but didn't have this code... is there any designer way of doin it or is it hard coding... Thanx

            haseeb

            V Offline
            V Offline
            vishalg_gupta
            wrote on last edited by
            #5

            didn't the blog http://openreferals.com/blogs/post/How-to-use-LINQ.aspx[^] helped you. You can write up comment there also if you want direct help from me. you can try something like var x = from x in (from person in Accounts join p in AccountPermissions on person.AccountID equals p.AccountID select new { userID = person.AccountID, per = p.PermissionID} ) where x.AccountID == 5 select x;

            1 Reply Last reply
            0
            • H haseeb_saeed

              I am trying to do a join using linq. i have 2 tables oempart and parttypes. i want to carry out join in linq and select only rows where oempart.id=5; my sql select statement is : (sql statement works fine) Select oemparts.name,parttypes.id,parttypes.product_type from oemparts join parttypes on oemparts.parttype_id=parttypes.id where parttypes.id =5 i want to do same with linq. i tried alot but can't do it. Please help... Question 2: Also this application has been developed partly by other programmer who had very good idea of linq. As i see, his sql to linq file (dbml) has a lot of coding... eg [table(name="dbo.oemparts")] and then 100 lines of code, similar case for associations etc... I want to know if such code is hardcoded or is produced by vs2008. i tried making linq to sql file from scratch but didn't have this code... is there any designer way of doin it or is it hard coding... Thanx

              haseeb

              S Offline
              S Offline
              SayreCC
              wrote on last edited by
              #6

              hi, try this var q = from a in dbc..... inner join b in dbc...... where b.....==textbox1.text for question number 2: about your example something code generated. Hope this one can help Thanks

              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