Reputation: 743
I am wondering if it is possible to create an XmlProvider from the data provided by an SqlDataProvider.
Naively it would be something like this:
type sql = SqlDataProvider<...>
let xml =
query {
for item in sql.GetDataContext().Main.Items do
select item.XmlData
head
}
type xmlType = XmlProvider<xml>
Of course this fails because xml is not a literal.
I'm curious if this is possible.
Upvotes: 1
Views: 70
Reputation: 1188
The short answer is: Yes.
And then the ifs and buts:
Given that the returned xml is structured (as in: about equal each time) then providing an example which is a literal would be ok.
Then the data from the database could be parsed like:
let someXmlDataNowType = xmlType.Parse(xml)
This is probably not what you want or asked about, but then again the short answer is: No ;-)
If you have a lot of queries with different XML my take would have been to write some code to generate the different XML in some files and even possibly write the f# automagically...
Upvotes: 1