Closed jamescheney closed 10 years ago
This exception is being raised by the following code in Query.fs:
| Patterns.PropertyGet(Some(Variable(None, _db)), _tbl, []) as e -> match e.Type with | QuerySourceTy(ty, _) -> Table(e, ty) // assume it's a db table ref | TableTy ty -> Table(e, ty) // assume it's a db table ref | ty' -> failwithf "Unexpected table reference %A %A" e ty'
It looks like we need to recognize [System.Data.Services.Client.DataServiceQuery`1[UnitTestProject1+Northwind+ServiceTypes+Customer]] as an allowed table type. Is there a good way of recognizing all of the possible table types?
Now fixed.
Although the fix addresses the specific issue, I believe it is highly specific to the System.Data.Services.Client.DataServiceQuery<T>
type.
First off, the exception occurs as the only variable references valid in a query are those querying a database table, and the DataServiceQuery<T>
type is not recognized as such.
Before this issue was posted the code had checked if a variable was of type Microsoft.Fsharp.Linq.QuerySource<T,Q>
or System.Data.Linq.Table<T>
to determine if it is a table, and commit a0b17898 added an explicit check to test if a variable is of type DataServiceQuery<T>
(along with an extra reference for the library).
I observed that both DataServiceQuery<T>
and Table<T>
implement the System.Linq.IQueryable<T>
interface which is also the base unwrapped type all query methods work with. On the other hand, the Microsoft.Fsharp.Linq.QuerySource<T,Q>
type is the wrapped type they use.
I thus believe checking for those two types, including for subtypes of the former, would be both correct and sufficient.
Queries
For example, the following simple query over the Northwind database provided by ODataService fails. (Additional examples are in the new file NorthwindTests.)
The error message is: