Queries against in-memory ODataEntities can have type inference issues
madelson opened this issue · comments
madelson commented
Here's a sample which repros the issue:
void Main()
{
var data = new[] {
new Dictionary<string, object>{ { "D", 1.1 }, { "I", 1 } },
new Dictionary<string, object>{ { "D", 4.9 }, { "I", 4 } },
new Dictionary<string, object>{ { "D", 9.2 }, { "I", 9 } },
}.Select(kvps => new ODataEntity(kvps))
.AsQueryable();
var nameValueCollection = new NameValueCollection();
nameValueCollection.Add("$format", "json");
nameValueCollection.Add("$filter", "D gt 5.0");
//nameValueCollection.Add("$filter", "D gt 5"); // this version fails casting 1.1 to int
var service = new ODataService();
var result = service.Execute(data, nameValueCollection);
result.Dump();
}
A possible fix could be to special-case enumerable queries and handle them in a mode that tries the compiled expression but falls back to doing the same thing with dynamic.