I want to understand how I can make Include a specific field from List in MongoDBdriver (any solutions)
When i try to Include some property For example:
var projection = Builders <SomeClass> .Projection
.Include (x => x.Id)
Its works without any problems.
But when i tryed to include a specific field from a sheet
var projection = Builders <SomeClass> .Projection
.Include (x => x.ListOfSomeClasses.Select (x => x.SomeProperty))
I get this exception
Error occurred during request execution
System.InvalidOperationException: Unable to determine the serialization information for x => x.ListOfSomeClasses.Select (x => x.SomeProperty).
Before that, I worked with postgres and there were no such problems there.
Perhaps there are some problems in Mongo with this. Any answers very helps me. Thank you
CodePudding user response:
c# driver allows using a raw MQL for LINQ queries that are not supported in typed way:
var projection = Builders<SomeClass>.Projection
.Include("ListOfSomeClasses.SomeProperty");