Closed rhalaly closed 5 years ago
did you found any solution for this ?
Ok got it 😁 For the records: I used JsonSubTypes (https://github.com/manuc66/JsonSubTypes#serializeobject-and-deserializeobject-with-custom-type-property-only-present-in-json)
public class ParentClass { }
[SharedCosmosCollection("Store", "ClassA")]
public class ChildClassA : ISharedCosmosEntity
{
...
public string CosmosEntityName { get; set; }
}
[SharedCosmosCollection("Store", "ClassB")]
public class ChildClassB : ISharedCosmosEntity
{
...
public string CosmosEntityName { get; set; }
}
var jsonSerializerSettings = new JsonSerializerSettings
jsonSerializerSettings.Converters.Add(
JsonSubtypesConverterBuilder
.Of(typeof(ParentClass), "CosmosEntityName")
.RegisterSubtype(typeof(ChildClassA), "ClassA")
.RegisterSubtype(typeof(ChildClassB), "ClassB")
.SerializeDiscriminatorProperty()
.Build()
);
I tried to create a "Polymorphic Store" that will return multiple types in one query. For example:
And I want to get in one query all the
Bar
&Baz
classes in one query. They both stored in a shared collection.Doing such thing:
will return empty result, since cosmonaut adds
CosmosEntityName == 'foo'
.If I disable the "IsShared" property with reflection:
will return ALL the
Foo
s classes, but it will not fill the properties that are defined inBar
andBaz
classes, but only theFoo
(base class) properties.So I didn't found any way to receive
Bar
&Baz
in one query. Does Cosmonaut support it?