Anda dapat menentukan proyeksi Anda seperti ini:
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 })
Anda kemudian dapat menggunakannya dengan cara berikut:
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