471,624 Members | 1,778 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,624 software developers and data experts.

LINQ dataContext reports wrong parameter type?

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?

Jun 27 '08 #1
2 2251
Andy B wrote:
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>

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Jun 27 '08 #2
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).
"Martin Honnen" <ma*******@yahoo.dewrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
Andy B wrote:
>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>

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/

Jun 27 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by =?Utf-8?B?SHlwZXJjb2Rlcg==?= | last post: by
4 posts views Thread by =?Utf-8?B?RXJpYyBGYWxza2Vu?= | last post: by
2 posts views Thread by Neil Chambers | last post: by
21 posts views Thread by hrishy | last post: by
1 post views Thread by Mike Gleason jr Couturier | last post: by
3 posts views Thread by =?Utf-8?B?UGF1bCBQcmV3ZXR0?= | last post: by
reply views Thread by bob laughland | last post: by
3 posts views Thread by bob laughland | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.