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. Entity Framework Question

Entity Framework Question

Scheduled Pinned Locked Moved C#
questiondatabasehelpcsharplinq
1 Posts 1 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.
  • J Offline
    J Offline
    Juvil John
    wrote on last edited by
    #1

    How do I instantiate an EntityObject with a Referencekeys for browsable objects. I'd like to do an XML to LINQ then convert it back as an entity object. now my problem is when I do this.

    GIVEN:
    XML from store procedure
    <Peoples>
         <People>
              <Name>name1</Name>
              <Work><Work>
              <Nickname>name1nick</Nickname>
         </People>
    </Peoples>
    
    People --> EntityObject
    People.Work --> Browsable Object (one to many relation)
    People.NickName --> Extended property, not a EdmScalarPropertyAttribute (just a simple custom scalar string property)
    
    var list = from peoples in XMLResult.Descendants("Peoples")
    select new People
    {
    Name = peoples.Element("Name").Value,
    Work = ??? (How do I load the this?), should I do (Work = _ObjectContext.Work.WorkID.Equals(peoples.Element("Work").Value), "Query in the object context?"
    Nickname = peopls.Element("Nickname").Value
    };
    
    Now you might be thinking why not just do this...
    
    var list = from people [ObjectContext].People
    select people;
    

    The reason is because People.NickName property is not a Table column, the data is generated from the stored procedure (which I had other processes) and is return as XML; If i skip People.Work it would give an error. hope its clear.

    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