0

I have a table in an SQL database, where the table configuration corresponds to

ID
Name string
data xml

where the datafield might (but not necessarily) contain a descendant element

<config>Some value...</config>

Using LINQ I want to select all the rows that has a data xml element which contains the config element with a value of... say 17.

My approach has been something like:

var query = from x in db
            from y in x.data.descendants("config")
            where y.Value == "17"
            select x;

But this throws an exception about the Value not being valid.

How should I formulate this query?

Regards, Casper

1

1 Answer 1

1

I am pretty sure that Linq 2 SQL does not support what you are trying to do. You would probably need to write a custom SQL statement or use a user defined function as discussed in the solution to this SO question: Can LINQ to SQL query an XML field DB-serverside?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.