المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Entity Framework Question



C# Programming
07-13-2009, 01:10 PM
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


name1

name1nick



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.