Support for SQL xml data type
-
Thursday, July 22, 2010 2:27 PM
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.
All Replies
-
Thursday, July 22, 2010 3:49 PMOn 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 XMLinside 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 anobject, which can be used by any .NET class VB or C#.
-
Thursday, July 22, 2010 4:15 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 5:15 PMOn 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 acontrol.>> 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 customobject like a DTO (Data Transfer Object) or an EF entity object is sentbetween the WCF client and service as an example, only primitive typedata can be sent like int, bool, string, double or any object-graph sentwithin 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 thatcan 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 objectad-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 theirinteractions to design applications and computer programs.The key concepts of OOP are the following:ClassObjectInstanceMethodMessage passingInheritanceAbstractionEncapsulationPolymorphismDecouplinghttp://en.wikipedia.org/wiki/Object-oriented_programmingNo 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 structuredand formalized format.Also so because SQL server can work with XML in a structured andformalized manner as XML, which can be en-queued/de-queued to/from aqueue by means of a SQL Server Service Broker and CLR in a brokermessage queue as XML and worked with by the SQL Server Service Broker asXML 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 Frameworkform that uses Linq-2-Entities.
-
Friday, July 23, 2010 5:13 AMModerator
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 SunMSDN 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. -
Monday, July 26, 2010 3:06 PM
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.
"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
-
Friday, August 26, 2011 8:40 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

