I'm want to create a method which would construct an equivalent of query { ... } computation expression (using FSharp.Data.TypeProviders with either LINQ2SQL or LINQ2Entities) from provided data structure, i.e.:
Collection("customers", [
Field "customerId";
Collection("orders", [
Field "orderId" ]) ])
For that I need to understand how the query is translated into code on the first place. Given following query as an example:
query {
for c in db.Customers do
select (c.CustomerID, query {
for o in c.Orders do
select o.OrderID
} |> Seq.toList)
}
What would it look like without computation expression syntax?
for ... intranslates into a call to theForfunction on the builder type. To get the exact code emitted, you can always use a decompiler. - Luaanqueryexpression. I've also tried to read decompiled code. This however query's body turns out to be a mixing of typeof's and byte numbers written directly into an array and called using single method - probably part of that query body is in fact a F# quotation. Nor particulary readable for humans thou. - Bartosz SypytkowskiFSharp.Data.TypeProviderswith LinqToSql in the example). 2. Also I need to return entities with nested one-to-many relationships (also presented in the example). So Dapper-like provider won't help me. Also erasing type providers will probably fail here. 3. I clearly mentioned that I need to deconstruct aquery(all type providers exposingqueryexpression work on SQL databases). - Bartosz Sypytkowski