Hello
I am sorry if this has been asked before, but I can't seem to find any reference to it.
I have an xml column in my db table and I want to return all rows where a particular node exists in the xml column.
I have managed to return the value true or false for the query in my datatable by doing as follows (taken from a previous thread one of my collegeus wrote)
string xquery = "//part[@name=\"" + partName.ToLower() + "\"]";
ResultsetFields fields = new ResultsetFields(3);
fields.DefineField(PricePartFields.PricePartId, 0);
fields.DefineField(PricePartFields.Name, 1);
fields.DefineField(PricePartFields.PricePartQuery, 2);
XQueryExpression expression = new XQueryExpression(PricePartFields.PricePartQuery, xquery,XQueryExpression.QueryMethods.Exist);
fields[2].SetExpression(expression);
DataTable dynamicList = new DataTable();
using (DataAccessAdapter adapter = new DataAccessAdapter())
{
adapter.FetchTypedList(fields,
dynamicList,
bucket, 0,
null, true, null);
}
return dynamicList;
This produces a query something like this:
SELECT [dbo].[PricePart].[PricePartId], [dbo].[PricePart].[Name], PricePartQuery.exist('//part[@name="markup"]') AS [PricePartQuery] FROM [dbo].[PricePart]
Now I want to run a very similar query, but I need to have a where clause that reads
Where PricePartQuery.exist('//part[@name="markup"]') =1
Do you have suggestions as to how I would accomplish this?
Thanks
Bex