次のように予測を定義できます:
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 })
その後、次のように使用できます。
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