Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/292.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#Mongo驱动程序:如何查询列表列表?_C#_Mongodb - Fatal编程技术网

C#Mongo驱动程序:如何查询列表列表?

C#Mongo驱动程序:如何查询列表列表?,c#,mongodb,C#,Mongodb,我有两个目标 public class ParentObject { [BsonId] public Guid Id { get; set; } public List<ChildObject> ChildObjects{ get; set; } } public class ChildObject { public DateTime DateTime { get; set; } public string Message{ get; set

我有两个目标

public class ParentObject
{
    [BsonId]
    public Guid Id { get; set; }
    public List<ChildObject> ChildObjects{ get; set; }
}

public class ChildObject
{
    public DateTime DateTime { get; set; }
    public string Message{ get; set; }
}
我还尝试了LINQ,但由于不支持表达式树,因此无法对其进行翻译:

            var result = mongoDb.Collection.AsQueryable()
                .Where(x => x.Id== request.Id)
                .Select(x => x.ChildObjects.OrderBy(c => c.DateTime).Take(10))
            .FirstOrDefault();
错误消息:
System.NotSupportedException:表达式树中不支持方法OrderBy:{document}{ChildObjects}.OrderBy(c=>c.DateTime)。

如何编写此查询?以及如何确保它在服务器端运行?是否有可能看到翻译后的查询

            var result = mongoDb.Collection.AsQueryable()
                .Where(x => x.Id== request.Id)
                .Select(x => x.ChildObjects.OrderBy(c => c.DateTime).Take(10))
            .FirstOrDefault();