LINQ dataContext reports wrong parameter type?

A

Andy B

Hi...

I have an sql server 2005 database that has a table called TestXml in it.
The table has the columns ID (identity, int) and MyXml(xml). I created a
stored proc on the server to insert a row into the table. It looks like
this:

create procedure InsertRow(@xmlDocument xml)
as
insert into TestXml values(@xmlDocument);

I created a new linq class by adding (in vs2008) a linq classes file and
called it TestXml.dbml. I opened the o/r designer and drug the TestXml table
from server explorer onto the designer. I then drug the stored proc listed
above from server explorer onto the designer. When it was listed in the
methods list, it had this for the signature:
InsertRow(System.Xml.Linq.XElement XmlDocument). I didn't want the intput
paramater to be an XElement since I haven't ever heard of it before. It was
supposed to be an XmlDocument object being inserted instead. Any ideas why
this happened? Do I need to convert all of my XmlDocuments to Xelements now?
 
M

Martin Honnen

Andy said:
I have an sql server 2005 database that has a table called TestXml in it.
The table has the columns ID (identity, int) and MyXml(xml). I created a
stored proc on the server to insert a row into the table. It looks like
this:

create procedure InsertRow(@xmlDocument xml)
as
insert into TestXml values(@xmlDocument);

I created a new linq class by adding (in vs2008) a linq classes file and
called it TestXml.dbml. I opened the o/r designer and drug the TestXml table
from server explorer onto the designer. I then drug the stored proc listed
above from server explorer onto the designer. When it was listed in the
methods list, it had this for the signature:
InsertRow(System.Xml.Linq.XElement XmlDocument). I didn't want the intput
paramater to be an XElement since I haven't ever heard of it before. It was
supposed to be an XmlDocument object being inserted instead. Any ideas why
this happened? Do I need to convert all of my XmlDocuments to Xelements now?

LINQ to SQL maps xml columns to the System.Xml.Linq.XElement, that is
correct. XElement is documented here:
<URL:http://msdn2.microsoft.com/en-us/library/System.Xml.Linq.XElement.aspx>
respectively the general LINQ to XML documentation is here:
<http://msdn2.microsoft.com/en-us/library/bb387098.aspx>

Why do you think that it should be System.Xml.XmlDocument? I think it
was System.Xml.Linq.XDocument for a while but that was changed:
<URL:http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2170562&SiteID=1>
 
A

Andy B

Not saying it "has to be" XmlDocument. Just got me off guard is all. Used to
seeing auto generators like o/r designer mapping to the same dataTypes (like
in a dataSet). Well, now that I think about it, maybe linq is more right
when it says the input parameter should be Xelement (it's closer than what a
dataSet would do with just string).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top