我正在使用Map Reduce索引进行查询。我想选择licenceId / licenceIds过滤器,它可以是一个或多个用文本框中输入的逗号分隔
e.g。
L1 (select having LicenseId only L1)
L1,L2 (select having LicenseId only L1 OR L2)
L2,L3,L5 (select having LicenseId only L3 OR L3 OR L5)
这是结果文件:
public class GrossSalesByRevenueClass
{
public string LicenseId { get; set; }
public string RevClass { get; set; }
public decimal GrossSales { get; set; }
public decimal NetSales { get; set; }
public int Quantity { get; set; }
public bool NonSales { get; set; }
public DateTime Day { get; set; }
public string DayName { get; set; }
public int Month { get; set; }
public int Quarter { get; set; }
public int Year { get; set; }
}
索引是:
public class IdxGrossSalesByRevenueClassByDay : AbstractIndexCreationTask<Ticket, GrossSalesByRevenueClass>
{
public IdxGrossSalesByRevenueClassByDay()
{
Map = docs => from doc in docs
from c in doc.Coversfrom t in c.TicketItems
select new
{
LicenseId = doc.LicenseId,
RevClass = t.RevenueClass,
GrossSales = t.TicketItemGross,
NetSales = t.NetPrice,
Quantity = t.Quantity,
NonSales = t.IsNonSales,
Day = doc.TicketDate.Date,
DayName = doc.TicketDate.ToString("ddd")
};
Reduce = result => from r in result
group r by new { r.NonSales, r.RevClass, r.Day, r.LicenseId } into g
select new
{
LicenseId = g.Key.LicenseId,
RevClass = g.Key.RevClass,
GrossSales = g.Sum(x => x.GrossSales),
NetSales = g.Sum(x => x.NetSales),
Quantity = g.Sum(x => x.Quantity),
NonSales = g.Key.NonSales,
Day = g.Key.Day,
DayName = g.Select(x => x.DayName).FirstOrDefault(),
};
}
}
我正在追问如下:
GrossSalesByRevenueClassCollection = session.Query<GrossSalesByRevenueClass, IdxGrossSalesByRevenueClassByDay>()
.TransformWith<GrossSalesByRevenueClassTransformer, GrossSalesByRevenueClass>()
.Where(x => x.Day >= d1 && x.Day <= d2 && (?????))
代替(?????)
,应该有许可证ID列表(L1 OR L2)
我尝试Contains()
在哪里但不为我工作请告诉我如何查询索引
满足这样的要求。
答案 0 :(得分:1)
类似这样的事情
var licenses = userLicenses.Split(",");
GrossSalesByRevenueClassCollection = session.Query<GrossSalesByRevenueClass, IdxGrossSalesByRevenueClassByDay>()
.Where(x => x.Day >= d1 && x.Day <= d2 && x.LicenseId.In(licenses))