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. How to include child property of LINQ to SQL object?

How to include child property of LINQ to SQL object?

Scheduled Pinned Locked Moved C#
databasetutorialcsharplinqquestion
2 Posts 2 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.
  • G Offline
    G Offline
    Goalie35
    wrote on last edited by
    #1

    I'm pulling in a sql table via linq to sql called "Employee". There are a total of 11 fields within this Employee table, so my LINQ automatically creates properties such as the following: Employee.Name Employee.Address Employee.Phone etc... I now however, need to add a child property to each of these properties called "Location", but I'm not sure how I would do this. So for example, I would need to use code such as the following: Employee.Name.Location = 1; Employee.Address.Location = 2; Employee.Phone.Location = 3; etc... I know I could set this "Location" up directly within my linq to sql dbml file, however anytime I update my database, my dbml file would be overwritten, so I'd prefer to avoid that. Is there any other way I can setup this "Location" child property? Thanks.

    M 1 Reply Last reply
    0
    • G Goalie35

      I'm pulling in a sql table via linq to sql called "Employee". There are a total of 11 fields within this Employee table, so my LINQ automatically creates properties such as the following: Employee.Name Employee.Address Employee.Phone etc... I now however, need to add a child property to each of these properties called "Location", but I'm not sure how I would do this. So for example, I would need to use code such as the following: Employee.Name.Location = 1; Employee.Address.Location = 2; Employee.Phone.Location = 3; etc... I know I could set this "Location" up directly within my linq to sql dbml file, however anytime I update my database, my dbml file would be overwritten, so I'd prefer to avoid that. Is there any other way I can setup this "Location" child property? Thanks.

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      Okay I just went cross eyed trying to relate Linq to database design. I'm sorry but I need to go back to the fundamental of the underlying data structure. Create the following tables Person Locations/Addresses(these are probably the same thing as a Location will only have 1 address presumably. PhoneNumbers has a foreign key PersonID lnkPersonLocation - allows many to many links between location and person with a FK to both tables

      Never underestimate the power of human stupidity RAH

      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