none
Support for SQL xml data type

    Question

  • The Enitity model maps SQL Server xml data type to String. (SqlMetal maps it to XElement).

    Any plans on supporting xml data type.

    Maybe I misunderstand but the entity is suposed to be the Object representation of my data so I should be able to use any .NET class. Right?

    Thanks.

    Thursday, July 22, 2010 2:27 PM

Answers

  • I posted the question because I found the following from about a year ago and wanted to see where the things are going. Apperently nowhere.

    http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/fb290076-f97d-41f4-9801-505ccf5ef1d6

    "If your application requires the ability to query XML data, you can still take advantage of the benefits of LINQ queries by using LINQ to XML. For more information, see LINQ to XML.”


     


    I know this is not the Linq to SQL forum neither the WPF forum. But this is what I have in the XAML. It just doesn't work with the string from EF.

    Binding Path=Element[ExpiresOn].Value, UpdateSourceTrigger=PropertyChanged

    So let me answer the question for you.

    EF does not have any plans for supporting XML data type in the future.

    Thank you.

    • Marked as answer by StefanDP Monday, July 26, 2010 3:13 PM
    Monday, July 26, 2010 3:06 PM

All replies

  • On 7/22/2010 10:27 AM, StefanDP wrote:
    > The Enitity model maps SQL Server xml data type to String. (SqlMetal
    > maps it to XElement).
    >
    > Any plans on supporting xml data type.
     
    Plans for what? XML is just string data. If you want to work with XML
    inside an entity, then use Linq-2-XML.
     
    >
    > Maybe I misunderstand but the entity is suposed to be the Object
    > representation of my data so I should be able to use any .NET class. Right?
     
    EF entity is just another .NET class that is instantiated to be an
    object, which can be used by any .NET class VB or C#.
     
     
     
    Thursday, July 22, 2010 3:49 PM
  • I want to Bind to it in WPF using Xpath.

    EF Entity is just another .NET class but only supports the basic data types. So it's not exatly like any other .NET class.

    I wander why did they bother having xml data type in SQL server. It's just string data. And why would they create those XML namespaces?

    Or why did the Linq-to-SQL guys went through all the trouble:

    http://msdn.microsoft.com/en-us/library/bb386947.aspx#DefaultTypeMapping

    Thursday, July 22, 2010 4:15 PM
  • On 7/22/2010 12:15 PM, StefanDP wrote:
    > I want to Bind to it in WPF using Xpath.
     
    You can also easily use Linq-2-XML and bind the results (objects) to a
    control.
    >
    > EF Entity is just another .NET class but only supports the basic data
    > types. So it's not exatly like any other .NET class.
     
    What are you talking about? XML is primitive type string. If a custom
    object like a DTO (Data Transfer Object) or an EF entity object is sent
    between the WCF client and service as an example, only primitive type
    data can be sent like int, bool, string, double or any object-graph sent
    within a DTO or EF entity can only contain primitive data types.
    Behavior (methods) are not sent and are dropped out of the object.
     
    An EF Entity is an implicit serialized data contract object to WCF that
    can be sent between the WCF client and service.
     
    Any class supports primitive data types. Even if it's a complex type,
    the underlying type is still primitive.
     
    You may not understand OOP, and you may not understand the make-up,
    characteristics and concepts of an object. And the EF Entity object
    ad-hears to all of it, just like any other .NET class or object.
     
    What is Object-oriented-programming?
     
    (OOP) is a programming paradigm that uses "objects" and their
    interactions to design applications and computer programs.
     
    The key concepts of OOP are the following:
     
    Class
    Object
    Instance
    Method
    Message passing
    Inheritance
    Abstraction
    Encapsulation
    Polymorphism
    Decoupling
     
    http://en.wikipedia.org/wiki/Object-oriented_programming
     
    No matter what development platform Java, .Net or others OOP is OOP.
     
    http://math.hws.edu/eck/cs124/downloads/OOP2_from_Univ_KwaZulu-Natal.pdf
     
     
    >
    > I wander why did they bother having xml data type in SQL server. It's
    > just string data. And why would they create those XML namespaces?
     
    They created the XML namespaces to treat the string data as a structured
    and formalized format.
     
    Also so because SQL server can work with XML in a structured and
    formalized manner as XML, which can be en-queued/de-queued to/from a
    queue by means of a SQL Server Service Broker and CLR in a broker
    message queue as XML and worked with by the SQL Server Service Broker as
    XML is another reason.
    >
    > Or why did the Linq-to-SQL guys went through all the trouble:
     
    This is not the Linq-2-SQL forum. This is the ADO.NET Entity Framework
    form that uses Linq-2-Entities.
     
     
     
    Thursday, July 22, 2010 5:15 PM
  • Hi,

     

    I agree with darnold92 that we can easily use LINQ to XML to work on the XML column.  Also, based on the MSDN document, Migration Considerations (Entity Framework):

     

    The Entity Framework does not support a native-XML data type. This means that when an entity is mapped to a table with an XML column, the equivalent entity property for the XML column is a string. Objects can be disconnected and serialized as XML. For more information, see Serializing Objects (Entity Framework).

    If your application requires the ability to query XML data, you can still take advantage of the benefits of LINQ queries by using LINQ to XML. For more information, see LINQ to XML.

     

    Have a nice weekend, both!

     

     

    Best Regards,
    Lingzhi Sun

    MSDN Subscriber Support in Forum

    If you have any feedback on our support, please contact msdnmg@microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Friday, July 23, 2010 5:13 AM
    Moderator
  • I posted the question because I found the following from about a year ago and wanted to see where the things are going. Apperently nowhere.

    http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/fb290076-f97d-41f4-9801-505ccf5ef1d6

    "If your application requires the ability to query XML data, you can still take advantage of the benefits of LINQ queries by using LINQ to XML. For more information, see LINQ to XML.”


     


    I know this is not the Linq to SQL forum neither the WPF forum. But this is what I have in the XAML. It just doesn't work with the string from EF.

    Binding Path=Element[ExpiresOn].Value, UpdateSourceTrigger=PropertyChanged

    So let me answer the question for you.

    EF does not have any plans for supporting XML data type in the future.

    Thank you.

    • Marked as answer by StefanDP Monday, July 26, 2010 3:13 PM
    Monday, July 26, 2010 3:06 PM
  • I wander why did they bother having xml data type in SQL server. It's just string data. And why would they create those XML namespaces?

    Or why did the Linq-to-SQL guys went through all the trouble:

    http://msdn.microsoft.com/en-us/library/bb386947.aspx#DefaultTypeMapping

     

    The XML data type in SQL is NOT just string data.  It's treated differently.

    One of the advantages of the XML data type in SQL is the ability to use XQuery statements to query your XML data.

    Another advantage is the ability to have indexes on your XML, making it very quick to search for data in your XML columns.  You can create XML indexes on the paths, properties (attributes) and values.

    This would allow someone to do something like this:

    SELECT [Id]
      ,XmlCol.value('(//Student/FirstName)[1]','varchar(max)') StudentFirstName
     FROM [Records]
     WHERE XmlCol.exist('//Student/FirstName/text()[contains(.,"Fred")]') = 1
    

     


    • Edited by Makoto Friday, August 26, 2011 8:42 PM adding quote
    Friday, August 26, 2011 8:40 PM