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. Multiple Join Query

Multiple Join Query

Scheduled Pinned Locked Moved LINQ
csharpdatabasequestionvisual-studiolinq
2 Posts 1 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.
  • C Offline
    C Offline
    CSCarlsson
    wrote on last edited by
    #1

    Hi, I have a smallish database that is used to record bids and projects. I am new to data access development and LINQ so please forgive me if this is a daft question. :-O I am attempting to use LINQ to SQL to create a set of columns for populating a DataGridView using fields from multiple tables. My LINQ query is as follows: var bids = from bp in dc.BID_PROJECTs join company in dc.COMPANies on bp.Company_URN equals company.URN join pm in dc.EMPLOYEEs on bp.Management_Team_URN equals pm.URN select new { bp.BP_BPR, bp.BP_Title, bp.BP_Status, bp.BP_Type, company.Name, pm.Name }; The problem I am having is that both company and pm have 'Name' columns which causes Visual Studio to return the following when I attempt to compile: 'An anonymous type cannot have multiple properties with the same name' I have spent a long time looking for ways round this but to no avail, can I just apply an alias to one of the .Name properties? Thanks Jason

    Jason Brown C# Developer

    C 1 Reply Last reply
    0
    • C CSCarlsson

      Hi, I have a smallish database that is used to record bids and projects. I am new to data access development and LINQ so please forgive me if this is a daft question. :-O I am attempting to use LINQ to SQL to create a set of columns for populating a DataGridView using fields from multiple tables. My LINQ query is as follows: var bids = from bp in dc.BID_PROJECTs join company in dc.COMPANies on bp.Company_URN equals company.URN join pm in dc.EMPLOYEEs on bp.Management_Team_URN equals pm.URN select new { bp.BP_BPR, bp.BP_Title, bp.BP_Status, bp.BP_Type, company.Name, pm.Name }; The problem I am having is that both company and pm have 'Name' columns which causes Visual Studio to return the following when I attempt to compile: 'An anonymous type cannot have multiple properties with the same name' I have spent a long time looking for ways round this but to no avail, can I just apply an alias to one of the .Name properties? Thanks Jason

      Jason Brown C# Developer

      C Offline
      C Offline
      CSCarlsson
      wrote on last edited by
      #2

      DOH!!! :-O :-O :-O :-O var bids = from bp in dc.BID_PROJECTs join company in dc.COMPANies on bp.Company_URN equals company.URN join pm in dc.EMPLOYEEs on bp.Management_Team_URN equals pm.URN select new { bp.BP_BPR, bp.BP_Title, bp.BP_Status, bp.BP_Type, CompanyName = company.Name, PMName = pm.Name };

      Jason Brown C# Developer

      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