我能做到
var result = OAS_Questions.Count (oasq => oasq.Id!=0);
result.Dump();
Run Code Online (Sandbox Code Playgroud)
乃至
var result = OAS_Questions;
result.Dump();
Run Code Online (Sandbox Code Playgroud)
但是当我试图将"问题"的子对象包含在"Opitons"中时
var result = OAS_Questions.Include("OAS_QuestionOptions");
result.Dump();
Run Code Online (Sandbox Code Playgroud)
我看到以下错误
'System.Data.Linq.Table'不包含'Include'的定义,也没有扩展方法'Include'接受类型为'System.Data.Linq.Table'的第一个参数'(按F4添加使用指令或汇编参考)
我已经尝试添加对以下程序集引用的引用.
但是在编写查询时仍然无法使用扩展方法"Include()",它会产生语法错误.
如何在下面的文档中获得最大的sections.Id,其中collection._id = some parameter
{
"_id" : ObjectId("571c5c87faf473f40fd0317c"),
"name" : "test 1",
"sections" : [
{
"Id" : 1,
"name" : "first section"
},
{
"Id" : 2,
"name" : "section 2"
},
{
"Id" : 3,
"name" : "section 3"
}
}
Run Code Online (Sandbox Code Playgroud)
我在下面试过
db.collection.aggregate(
[
{
"$match": {
"_id": ObjectId("571c5c87faf473f40fd0317c")
}
},
{
"$group" : {
"_id" : "$_id",
"maxSectionId" : {"$max" : "$sections.Id"}
}
}
]);
Run Code Online (Sandbox Code Playgroud)
但是它不是返回 max int 单个值,而是返回部分数组中所有 Id 的数组。
在 node.js 中执行进一步相同的查询时,它返回一个空数组。