This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
hi - i was thinking this might have been a common question but i can't find anything in the forums.
unitofwork.MyEntities.Single(e => e.XmlPropertyMasqueradingAsAString.Contains(criteria)).
any ideas? cheers justin |
|
|
I don't think this is possible. The SQL Server xml data type doesn't appear to support a "string contains" method. It looks like the closest you can get is the query method, which takes an XQuery. (I don't know XQuery well enough to know whether you could create an XQuery for "string contains," but if your criteria are structured like an element plus specific attribute or content then that should be doable.) To use this in LINQ, you will need to use ServerFunctionDescriptor.Register to map a CLR method to the server-side query function. Since String contains no suitable methods, this will have to be an extension method. See http://www.mindscape.co.nz/blog/index.php/2009/08/10/custom-functions-in-linq/ for an example very similar to this. |
|
|
Uh, s/query/exists/. Sorry about that. |
|