Reputation: 167
My supervisor is under the impression that it is possible to run queries on a MySql database that run xPath queries on the xml documents stored.
The table I am concerned with is called Responses and has the following columns
UserId, UploadTime, RawXml
I already get all the responses for a particular user by
public ActionResult UserResponses(Guid userid)
{
var allResponses = ZodiacData.Responses;
var userResponses = (from r in allResponses
where r.UserId == userid
select r)
//...populate model here....
return PartialView("_responseTable", responsesmodel)
}
However now I am trying to get all the responses to a specific questionnaire which is referenced in the root node of the RawXml (by qid and qver, please see the example below) The root node:
<response qid="5" qver="3" date="..-..-.." qname="full">
Does anyone know how I can do that in asp.net, what should I add to the query in the function above? any help would be great, even if just a pointer to the right kind of articles online. Thank you!
Upvotes: 0
Views: 236
Reputation: 364369
Yes it is possible to run XPath queries on XML data in database but you cannot use EF for that because EF doesn't support that. If you want to use XPath in database queries you must write your SQL directly.
.NET 4.5 should change this little bit because you would be able to map table valued SQL function and hide that XPath query inside that function.
Upvotes: 2