473,232 Members | 1,425 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,232 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 2308
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Andy B | last post by:
I was just wondering, when you create dataContext methods, should you put business logic there to try and minimize pushing data through 2-3 layers of code? or should the business logic still go in...
0
by: =?Utf-8?B?SHlwZXJjb2Rlcg==?= | last post by:
I'm encountering some strange behavior after deploying a ASP.net 3.5 website to production, i'm unable to reproduce these in my dev environment. This error seems to occur very randomly but it's...
4
by: =?Utf-8?B?RXJpYyBGYWxza2Vu?= | last post by:
We’re storing our main entity in an insert only table which stores the history of past revisions, but we’re facing problems with storing this history as LINQ will only update the entity, and...
2
by: Neil Chambers | last post by:
All, I have a class describing various actions to take against a LINQ to SQL datasource. What are the pros/cons of instantiating the LINQ object either in the root of the class (for lack of a...
21
by: hrishy | last post by:
Hi Will LINQ be ported to Python ? regards Hrishy
1
by: Mike Gleason jr Couturier | last post by:
Hi, Is there any benefit to store a datacontext singleton in an application variable? Should I bother? Should I just create an instance of my datacontext every time my business objects...
3
by: =?Utf-8?B?UGF1bCBQcmV3ZXR0?= | last post by:
I'm attempting to use LINQ to insert a record into a child table and I'm receiving a "Specified cast is not valid" error that has something to do w/ the keys involved. The stack trace is: ...
0
by: bob laughland | last post by:
Hi All, I am using a combination of LINQ to SQL and bulk insert. In the process of performing 'one unit of work' I will be doing things like reading, and deleting records using LINQ to SQL and...
3
by: bob laughland | last post by:
Hi All, I am using a combination of LINQ to SQL and bulk insert. In the process of performing 'one unit of work' I will be doing things like reading, and deleting records using LINQ to SQL and...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...

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.