473,396 Members | 1,789 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,396 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 2314
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.