MongoDB Unable to determine the serialization information -
i'm having problem mongodb querying. here's classes:
class { } class b : { } class c : { public string prop1 { get; set; } } class d { public list<a> collection1 { get; set; } }
and query:
var query1 = query<d>.elemmatch(d => d.collection1.oftype<c>(), builder => builder.eq(c => c.prop1, "val1"));
in nutshell want select instances of class d collection "collection1" contains @ to the lowest degree 1 instance of class c property "prop1" equals "val1".
this keeps throwing "unable determine serialization info expression" out of blue.
what doing wrong? i've tried decorating "a" bsonknowntypes(typeof(b), typeof(c)) no avail.
ps: if had 1 class a:
class { public string prop1 { get; set; } } class d { public list<a> collection1 { get; set; } }
then code works , want:
var query1 = query<d>.elemmatch(d => d.collection1, builder => builder.eq(c => c.prop1, "val1"));
but it's not want, want maintain "b" , "c" inherit "a".
try use: nameof()
.
builder => builder.eq(nameof(c.prop1), "val1");
mongodb mongodb-csharp mongodb-query
No comments:
Post a Comment