2016-02-29 55 views
1

您好,我正在mongo c#驅動程序v2.2.3中,他們已經引入了連接操作($ lookup)。當我嘗試執行聯合操作時,我將聯合文檔收集計數設置爲零。我按照這個鏈接http://mongodb.github.io/mongo-csharp-driver/2.2/reference/driver/crud/linq/和我的代碼是加入操作不工作mongo c#驅動程序linq

var query = from c in collection1.AsQueryable<Class>() 
     join m in collection2.AsQueryable<ClassTwo>() on 
c.ClassTwoId equals m.Id into j select new { c,j }; 
    var r = await query.ToListAsync(); 

和我的課是..

public class Class 
    { 
     public ObjectId Id { get; set; } 
     public string SomeText{ get; set; } 
     public ObjectId ClassTwoId { get; set; } 
     public ObjectId ClassThrId { get; set; } 
     public DateTime CreatedDate { get; set; } 
    [BsonIgnore] 
     public ClassTwo ClassTwoDeatils { get; set; } 
} 

我不知道我做了錯誤...任何想法?

+0

一個方法是使用蒙戈探查器選項,看到的mongod實例生成查詢,請蒙戈分析數據庫操作的性能,並SETT打樣水平 - 2.這可能會對有關查詢的洞察力。 btw - 是最新的mongo驅動程序嗎? – profesor79

+0

是的,我從Nuget包管理器下載它 – Malar

+0

在mongo shell $ lookup函數工作正常,但我不能在c#驅動程序中複製相同的結果 – Malar

回答