Slice with Projection with C#

前端 未结 1 1661
星月不相逢
星月不相逢 2021-01-27 00:04

Is there any way to implement a slice along with a projection in just one query using the c# driver? Below is what i am trying to achieve using c#, but im stuck, can anyone help

相关标签:
1条回答
  • 2021-01-27 00:39

    There is a way to do this with the C# driver. Methods can be chanined on builders, so all of .Slice() and .Include()and .Exclude()

    var fields = Fields.Slice("empActivity", -1)
        .Include("employeeId", "empActivity.transId")
        .Exclude("_id");
    
    var cursor = collection.Find(query).SetFields(fields); 
    
    0 讨论(0)
提交回复
热议问题