2015-10-19 98 views
0

我不知道是什麼問題,但我必須做錯了,因爲索引是空的,即使我刪除where b.Status == ...行。 任何想法?RavenDB嵌套字典屬性索引

public class Bookings_ToBeScheduled : AbstractIndexCreationTask<Inspection, BookingRequest> 
{ 
    public Bookings_ToBeScheduled() 
    { 
     Map = inspections => 
      from i in inspections 
      from b in i.Bookings.Values 
      where b.Status == BookingStatus.Requested || b.Status == BookingStatus.InspectorAssigned 
      select new 
      { 
       InspectionId = i.Id, 
       i.InspectionType, 
       b.BookingNumber 
      }; 
    } 
} 

回答

0

試試這個,而是:

public class Bookings_ToBeScheduled : AbstractIndexCreationTask<Inspection, BookingRequest> 
{ 
    public Bookings_ToBeScheduled() 
    { 
     Map = inspections => 
      from i in inspections 

      select new 
      { 
       InspectionId = i.Id, 
       i.InspectionType, 
/* 
BookingNumber = i.Bookings.Values 
      .Where(b => b.Status == BookingStatus.Requested || b.Status == BookingStatus.InspectorAssigned) 
      .Selcet(b=> b.BookingNumber) 

*/ 
       BookingNumber = from b in i.Bookings.Values 
           where b.Status == BookingStatus.Requested || b.Status == BookingStatus.InspectorAssigned 
           select b.BookingNumber 
      }; 
    } 
} 

它一般最好不要在索引中的扇出(每個文檔多個條目)是。 我並不確定哪個版本的BookingNumber可以工作,Linq方法當然會。

+0

謝謝Ayende,我找到了解決方案。問題是從Dictionary中選擇'.Values',所以這對我有用 - 從i.Bookings中的b,然後使用b.Value.BookingNumber – CRG