I need to select rows from a database table using column filtering of type XML.
Tablelooks like (short version)
id
dbfield int
xmlfield xml
and I filter it this way
IQueryable<Data.entity> q = from u in datacontex.entities
select u;
if (val1.HasValue)
q = q.Where( x => x.dbfield > val1.value)
if (val2.HasValue)
q = q.Where( x=> x.dbfield < val2.value)
if (!string.IsNullOrEmpty(searchString))
q = q.Where ( x=> x.xmlfield contains values from searchString)
XML in xmlfield very simply looks like
<doc>
<item id="no">test/WZ/2009/04/02</item>
<item id="title">blabla</item>
...
The question is how to add the WHERE clause in linq and, preferably, this conversion should translate to the ms-sql query without processing the dataset in the webservice application.
Thanks.
source
share