Open NetTecture opened 6 years ago
Anyone cares about those? Because right now the ONLY way to get OData working with Entity Framework Core is for me to pull all data into memory and then hand that over to Odata - which is like the antithesis of how you should use sql server.
I'm facing the same problem! Hope someone here can help!
I am facing this issue too 🙁
Current 7.0 Nuget. This contains a number of correlated issues.
The following code:
results in an exception as the PageResult first line is null (results is NOT an IEnumerable. This is based on example code, but with dotnetcore etc. it is hard to remember where that came from. Documentation is definitely lacking.
var results if of type
1[Api.Odata.Tenant].Select(Param_0 => new SelectAllAndExpand
1() {ModelID = "ce35c6b0-2c6d-44b7-9ff8-51bed4c03018", Instance = Param_0, UseInstanceForProperties = True, Container = new NamedProperty1() {Name = "Buildings", Value = IIF((IIF((Param_0 == null), null, Param_0.Buildings) == null), null, IIF((Param_0 == null), null, Param_0.Buildings).Select(Param_1 => new SelectAll
1() {ModelID = "ce35c6b0-2c6d-44b7-9ff8-51bed4c03018", Instance = Param_1, UseInstanceForProperties = True}))}})}The funny thing is that this SHOULD be castable to Api.Odata.Tenant - it is not.
Changing
var results = (IQueryable) options.ApplyTo(objectList.AsQueryable());
To
var results3 = (IQueryable)options.ApplyTo(objectList.AsQueryable());
results in
System.InvalidCastException HResult=0x80004002 Message=Unable to cast object of type 'System.Linq.EnumerableQueryd__12.MoveNext()
1[Microsoft.AspNet.OData.Query.Expressions.SelectExpandBinder+SelectAllAndExpand
1[Api.Odata.Tenant]]' to type 'System.Linq.IQueryable1[Api.Odata.Tenant]'. Source=Api.Odata.Web StackTrace: at Api.Odata.Web.Controllers.TenantController.Get(ODataQueryOptions
1 options) in C:\Work\OBB\Source.Backend\Api.Odata.Web\Controllers\TenantController.cs:line 31 at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.SyncObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.As does casting it to IEnumerable of type
System.InvalidCastException HResult=0x80004002 Message=Unable to cast object of type 'System.Linq.EnumerableQueryd__12.MoveNext()
1[Microsoft.AspNet.OData.Query.Expressions.SelectExpandBinder+SelectAllAndExpand
1[Api.Odata.Tenant]]' to type 'System.Collections.Generic.IEnumerable1[Api.Odata.Tenant]'. Source=Api.Odata.Web StackTrace: at Api.Odata.Web.Controllers.TenantController.Get(ODataQueryOptions
1 options) in C:\Work\OBB\Source.Backend\Api.Odata.Web\Controllers\TenantController.cs:line 31 at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.SyncObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.There is no indication what the proper way is to move from this returned query to something I can enter into Page result.
What does make this worse is the bad exception in the constructor if PageResult. There isa null check in the constructor that reads:
as the parameter is called items - this results in a bad exception. This should read: