471,318 Members | 1,988 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Combination of Linq to sql and Linq to xml

Hi folks

I am pretty new to linq and in one of my first samples I tried to do
the following:

In my sample-database I have a table which has some columns and one of
them has the type 'xml'.

sample-data

ID varcharcolumn1 varcharcolumn2 xmlcolumn
1 test test
<xml><name>Test</name></xml>
2 test2 test2
<xml><name>nodata</name></xml>
Is it possible to get all Rows where the xml-Column has a node 'name'
with a Textnode that starts with 'T' using LINQ?

Thanks

Philipp Haenggi

Aug 7 '08 #1
1 1391
On Aug 7, 7:07*am, ph_haen...@yahoo.de wrote:
I am pretty new to linq and in one of my first samples I tried to do
the following:

In my sample-database I have a table which has some columns and one of
them has the type 'xml'.

sample-data

ID * * *varcharcolumn1 * *varcharcolumn2 * *xmlcolumn
1 * * * * * test * * * * * * * * * * *test
<xml><name>Test</name></xml>
2 * * * * * test2 * * * * * * * * * *test2
<xml><name>nodata</name></xml>

Is it possible to get all Rows where the xml-Column has a node 'name'
with a Textnode that starts with 'T' using LINQ?
Not easily - because the query is performed at the database side. If
the database has knowledge of XML there may be special SQL extensions
you could use - but they won't be generated by LINQ to SQL. You may be
able to get away with a regular expression (or simply use LIKE and
"<name>T" but that will be error prone if there could be attributes in
the elements etc. To actually use LINQ to XML to do the querying,
you'd have to pull all the XML from the database and then do the query
in-process.

Jon
Aug 7 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Dave Johnson | last post: by
7 posts views Thread by Chris | last post: by
28 posts views Thread by Marc Gravell | last post: by
9 posts views Thread by =?Utf-8?B?cmF1bGF2aQ==?= | last post: by
reply views Thread by =?Utf-8?B?SHlwZXJjb2Rlcg==?= | last post: by
4 posts views Thread by =?Utf-8?B?RXJpYyBGYWxza2Vu?= | last post: by
14 posts views Thread by thj | last post: by
3 posts views Thread by =?Utf-8?B?UGF1bCBQcmV3ZXR0?= | last post: by
reply views Thread by rosydwin | 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.