Puoi definire le tue proiezioni in questo modo:
let projection1 =
Builders<MyModel>.Projection.Expression(fun model ->
{ id = model.id; y = model.y })
let projection2 =
Builders<MyModel>.Projection.Expression(fun model ->
{ id = model.id; x = model.x; z = model.z })
Puoi quindi utilizzarli nel modo seguente:
let one =
collection
.Find(fun m -> m.z.zInner = false)
.Project(projection1).ToEnumerable() |> List.ofSeq
let two =
collection
.Find(fun m -> m.x = 5)
.Project(projection2).ToEnumerable() |> List.ofSeq
let three =
collection
.Find(fun _ -> true)
.Project(projection1).ToEnumerable() |> List.ofSeq
let four =
collection
.Find(fun _ -> true)
.Project(projection1).ToEnumerable() |> List.ofSeq