【发布时间】:2017-09-20 18:05:00
【问题描述】:
我在 RavenDB 中有一个包含子集合的文档。子集合包含以下基本类型。
public class Section
{
public string BackgroundColor { get; set; }
public string Description { get; set; }
public string DesktopBackgroundImageUrl { get; set; }
public DateTime? EndDate { get; set; }
public string MobileBackgroundImageUrl { get; set; }
public int SortOrder { get; set; }
public DateTime? StartDate { get; set; }
public string TextColor { get; set; }
public string Title { get; set; }
public SectionType Type { get; set; }
}
这个类型有几个派生类,其中之一就是this。
public class OfferSection : Section
{
public IEnumerable<Merchant> Merchants { get; set; }
}
我遇到的问题是我需要查询这个子集合并获取包含派生类型的文档,然后查询它的值。
到目前为止,这是我必须要做的,但是因为它使用的是基本类型,所以 Merchants 属性不存在
public class Hubs_ByMerchantId : AbstractIndexCreationTask<Hub>
{
public Hubs_ByMerchantId()
{
Map = hubs => from hub in hubs
select new
{
Sections_Merchants_Id = hub.Sections.Where(x => x.Type == SectionType.Offer).SelectMany(x => x.Merchants.Select(y => y.Id))
};
}
}
谁能指出我正确的方向?
谢谢
【问题讨论】: