Let's assuming 2 objects:
class A
{
string id;
List<B> items;
}
class B
{
string color;
string name;
}
I would like to do a query where:
_ => _.id == myqueryid && _.items.any(t => t.color == "yellow)
so far.. so good
now, I would like to recover only the B type object that was matched, not the whole object; how can I do that?
bonus question: is there a way to recover a single field from the B type object?
here's the code right now
var K = Driver.Find(_ => _.Id == Id && _.Items.Any(__ => __.Color == "Yellow"));
that part works. it recovers the right objects
var K = Driver.Find(_ => _.Id == Id && _.Items.Any(__ => __.Color == "Yellow").Project(P);
and my projection is:
Expression(_ => _.Ledger[-1])
but somehow I don't get the data I need. If I project to a dynamic and use Include, I get it (along with _id), but it's not ideal.
after more testing:
.Include(_ => _.items[-1].color).Exclude(_ => _._id));
I would expect this to return color, but it returns the matching B object...