none
How to Use Entity Frame work With XML field's in Relational Database RRS feed

  • Question

  • Hi ,

    I want to make a n-tier application with ado.net Data services . but i have a big problem .

    I have a Database that Contains a Table with xml Data . this Table have Six columns .

     

    Persons

    --> intPersonID (int)

    --> xmlContent (xml)

    --> dtmLastModified (datetime)

    --> dtmCreationDate (datetime)

    --> intCreatorID (int) 

    --> intLastModfierID (int) 

     

     

    In the xmlContent Field I Have Three Node Like This :

     

    Code Snippet

    <Person>

    <PersonInfo>

       <FullName>jfk lop</FullName>

       <Name>jfk</Name>

       <Family>lop</Family>

    <PersonInfo>

    <Internet>

    <Email type="private">

    jkf@somewhere.com

    <Email>

    <Email type="public">

    jkf@somewhere.com

    <Email>

    </Internet>

     

    <Addresses>

    <Address type="Home"> every where may I raom . <Address>

    <Address type="Work"> every where may I raom 2 . <Address>

    </Address>

     

    </Person>

     

     

     

     

    so.....

     

    I want To Generate an Entity Model for This xml field and Crud Operation Like The Relational Databases .

     

    so , How can I generate and Modify on this xml filed ?

    Any Idea ?

     

    Thanks .

     

    Saturday, September 27, 2008 8:45 AM

Answers

  • Unfortunately the EF does not support promoting parts of an XML column up as direct properties of an entity.  You can have an XML column as a property, but the property is treated as a string rather than having the EF map into the XML.  Building deeper integration with XML is something we've talked about for a future release but don't yet have a firm plan of when it will arrive.

     

    One thing you could consider doing is creating a view on your database which uses functions in the DB to expose parts of the XML as columns in the view and then use stored procedures to handle inserts, updates and deletes.  The EF could then be mapped to the view and the stored procedures.

     

    - Danny

     

    Sunday, September 28, 2008 2:58 AM