eZeeNow.com

it's your's

No mapping exists from object type System.Xml.Linq.XElement to a known managed provider native type.

 No mapping exists from object type System.Xml.Linq.XElement to a known managed provider native type.

Generally I think if you want to use LINQ to XML with MS SQL Server then you are better off to use LINQ to SQL together with LINQ to XML as that way I think you want call your stored procedure as a method of an object and that allows you to pass on a System.Xml.Linq.XElement to a stored procedure that takes an "xml" T-SQL data type value.


var xmlData = new XElement("Posts", from i in posts
                                                            select new XElement("Post", new XElement("Title", i.Title),
                                                                new XElement("Description", i.Description),
                                                                new XElement("Categories", i.Categories),
                                                                new XElement("Links", i.Links),
                                                                new XElement("Tags", i.Tags),
                                                                new XElement("PublicationDate", i.PublicationDate)));
                     

This

SqlParameter() { ParameterName = "@data", Value = xmlData , SqlDbType= System.Data.SqlDbType.Xml}


SqlParameter() { ParameterName = "@data", Value = xmlData.ToString() , SqlDbType= System.Data.SqlDbType.Xml}
Loading