Closed arex388 closed 4 years ago
Hello @arex388 ,
Thank you for reporting. We will look at it.
I believe we need now to find another solution to handle the QueryFuture for 3.x
Hey @JonathanMagnan ,
For now I've got a bandaid where I've got computed columns to project the geography to a varchar(max), then I do a bunch of string splitting client side and re-create the Point or Polygon. Works for now.
I take it by your comment that EF Core 3.X+ is making things difficult?
Initially, we only had the issue with Oracle
since they were casting our internal command into a OracleCommand
in their ExecuteReader
method (or somewhere else, I'm not 100% sure to remember).
But a few weeks, someone reported a similar issue with PostgreSQL
and now you with SQL Server
.
The code was initially made for EF Core 2.x
, so perhaps, we could find a better solution with EF Core 3.x
Just a note, this same issue occurs with .IncludeOptimized as well.
Hey @arex388 , Just a thought, but you could STAsText() in your computed column, which converts the Geography's to Well known Text (WKT). Then on the client side, use NetTopology to convert the WKT back to your point or polygon. Just a thought, but it may simplify your complexity a bit until a fix is found.
@djjeffg382 I updated my computed columns to your recommendation and it's definitely much easier to re-create them back on the client side now. Thanks!
Hello @arex388 and @djjeffg382 ,
We really took a lot of time in the past 2 weeks to find a solution but unfortunately, we didn't find one that worked correctly ;(
The IncludeOptimized
method indeed uses the QueryFuture feature under the hood, so as you reported @djjeffg382 , the same issue is found on this one.
We will sure re-visit this issue in the future but for now, I guess we need to "abandon" it for a few weeks since we don't make any good progress at this moment ;(
Any news about this problem ? I have the same error in my project with the use of the IncludeOptimized instruction on an object that contains a Point (NetTopologySuite) property. This problem is very annoying :(
System.InvalidCastException: Unable to cast object of type 'Z.EntityFramework.Plus.CreateEntityDataReader' to type 'Microsoft.Data.SqlClient.SqlDataReader'.
at lambda_method(Closure , QueryContext , DbDataReader , ResultContext , Int32[] , ResultCoordinator )
at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable`1.Enumerator.MoveNext()
at Z.EntityFramework.Plus.QueryFutureValue`1.SetResult(DbDataReader reader)
at Z.EntityFramework.Plus.QueryFutureBatch.ExecuteQueries()
at Z.EntityFramework.Plus.QueryFutureValue`1.get_Value()
at Z.EntityFramework.Plus.QueryIncludeOptimizedProvider`1.Execute[TResult](Expression expression)
at Z.EntityFramework.Plus.QueryIncludeOptimizedProvider`1.<>c__DisplayClass14_0`1.<ExecuteAsyncTask>b__0()
at System.Threading.Tasks.Task`1.InnerInvoke()
at System.Threading.Tasks.Task.<>c.<.cctor>b__274_0(Object obj)
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
Hello @JonathanMagnan , do you have any idea on when this problem should be resolved?
Know if I'm patient or if I'm going for another solution.
Hello @StevenHanquez ,
We have not done any progression. We need to find another way to make this feature since it break inside of the provider which makes some cast.
So you should probably go with another solution since we don't know when it will be fixed ;(
Hey Jonathan,
Just wanted to ask if there was any hope for this to work again? Maybe in EF Core 5?
I will ask my developer to look if there is some hope with the current EF Core 5 preview-8
Unfortunately, we didn't succeed @arex388 ,
The cast is done inside Entity Framework.
The only way to fix it is probably to re-write some parts of this feature to remove some requirement such as using some custom reader.
At this moment, due to some time limitation, that's currently impossible but that's definitely something we will need to investigate to make sure this library stay up to date.
Ok. Unfortunate but it is what it is. Thanks for taking a look again and hopefully in the future this can be resolved. Thanks!
Hello arex388,
Thanks for your comprehension
Don't hesitate if you have any questions.
Best regards
Jon
Description
In my DbContext I have entities that use Net Topology Suite's Point and Polygon objects for properties. When attempting to use
FutureValue()
(and probablyFuture()
) to select an entity results in an exception.Exception
EF Plus seems to be having a hard time with NTS, but it is the officially recommended library for geospatial data with SQL Server so I'm kind of stuck.
Further technical details