zzzprojects / EntityFramework-Plus

Entity Framework Plus extends your DbContext with must-haves features: Include Filter, Auditing, Caching, Query Future, Batch Delete, Batch Update, and more
https://entityframework-plus.net/
MIT License
2.27k stars 318 forks source link

Entities with spatial types are not read/materialized. #782

Closed bfbrown closed 1 year ago

bfbrown commented 1 year ago

1. Description

Entities with spatial types are not read/materialized.

2. Exception

Exception message: 
System.InvalidCastException : Unable to cast object of type 'Z.EntityFramework.Plus.CreateEntityDataReader' to type 'Microsoft.Data.SqlClient.SqlDataReader'.

Stack trace:
lambda_method139(Closure, QueryContext, DbDataReader, ResultContext, SingleQueryResultCoordinator)
Enumerator.MoveNext()
QueryFutureEnumerable`1.SetResult(IEnumerator`1 enumerator)
QueryFutureEnumerable`1.SetResult(DbDataReader reader)
QueryFutureBatch.ExecuteQueries()
QueryFutureEnumerable`1.GetEnumerator()
List`1.ctor(IEnumerable`1 collection)
Enumerable.ToList[TSource](IEnumerable`1 source)
FutureTests.Future_queries_should_succeed() line 71
RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)

3. Fiddle or Project

Project files attached.

4. Any further technical details

This does not happen if you reuse a DbContext that previously worked with spatial types. FutureTests.zip

JonathanMagnan commented 1 year ago

Hello @bfbrown ,

Thank you for the project, we will look at it. However, if this is what we believe, I don't think we will be able to fix it until we re-write the Query Future code.

Best Regards,

Jon

bfbrown commented 1 year ago

Thank you, looking forward to a fix. Can you suggest any workaround until then?

JonathanMagnan commented 1 year ago

Hello @bfbrown ,

Unfortunately no.

After some investigation yesterday, we failed to find a way to fix it. The only way to make it work is to re-write some critical parts of that feature, which, unfortunately, we don't have the time to do at this moment.

So I will close this issue as: It will not be fixed as I'm not sure if we will ever re-write this feature

Best Regards,

Jon