You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not entirely sure if this is feasible, but I wanted to ask anyway just in case I was missing something obvious.
I am building a MassTransit-like package for my work. I want to give developers who use my package the ability to query a JsonDocument instance like they would with LINQ instead of relying on methods such as JsonDocument.RootElement.GetProperty("x")... for cases where Saga data needs to be manually manipulated.
I am currently relying on the JsonDocument type but wanted to see if I could make this work with the POCO mapping approach.
The insertion portion of this code works as expected, the issue I'm having is I can't figure out if it's possible to cast the JsonBaseEntity to a derived type. My plan was to create a generic method which would cast JsonEntity to the generic type provided by the user. This would allow developers to query the JSON entity with JSON-supported LINQ as is provided by example here.
My issue is with specifying a base type on the entity, and trying to cast that type to the actual type the dev is wanting to query for. When attempting to cast the entity to a derived type, I receive the following exception:
The LINQ expression could not be translated.
Thanks for any help and suggestions on this!
The text was updated successfully, but these errors were encountered:
@roji Perhaps the framework could check for the presence of the JsonPolymorphic attribute, and implicitly translate the query above to WHERE JsonEntity->>'type' == '<JsonDerivedEntity's_Type_from_JsonDerivedAttribute>' AND JsonEntity->>'IntTest' == 11?
This is definitely on the roadmap on the EF side (at which point it'll work also on PG), but is not implemented at this point (there's a good chance it will get done for 10).
I'm not entirely sure if this is feasible, but I wanted to ask anyway just in case I was missing something obvious.
I am building a MassTransit-like package for my work. I want to give developers who use my package the ability to query a
JsonDocument
instance like they would with LINQ instead of relying on methods such asJsonDocument.RootElement.GetProperty("x")...
for cases where Saga data needs to be manually manipulated.I am currently relying on the
JsonDocument
type but wanted to see if I could make this work with the POCO mapping approach.Here is a sample of what I am trying to achieve:
The insertion portion of this code works as expected, the issue I'm having is I can't figure out if it's possible to cast the
JsonBaseEntity
to a derived type. My plan was to create a generic method which would castJsonEntity
to the generic type provided by the user. This would allow developers to query the JSON entity with JSON-supported LINQ as is provided by example here.My issue is with specifying a base type on the entity, and trying to cast that type to the actual type the dev is wanting to query for. When attempting to cast the entity to a derived type, I receive the following exception:
The LINQ expression could not be translated
.Thanks for any help and suggestions on this!
The text was updated successfully, but these errors were encountered: