这是我域中的三个类:
public class Quote : IEntity, IAggregateRoot {
public int QuoteId { get; set; }
public IEnumerable<Price> Prices { get; set; }
}
public class Price : IEntity {
public int PriceId { get; set; }
public Carrier Carrier { get; set; }
public decimal? Price { get; set; }
public Quote Quote { get; set; }
}
public class Carrier : IEntity, IAggregateRoot {
public int CarrierId { get; set; }
public string Name { get; set; }
}
我希望能够根据报价单中的价格选择一个预测。返回类型应为 IEnumerable<[anonymous object]>。我必须从 Quote 开始查询,因为它是根域对象。这是我到目前为止所拥有的:
session.Linq<Quote>()
.Expand("Prices")
.Where(q => q.QuoteId == 1)
.Select(q => {
//this is where I don't know what to do.
//Maybe somthing like this:
return q.Prices.Select(p => {
new { CustomerName = p.Customer.Name, Price = p.Price }
});
});
映射将是:
- Quote.Prices > HasMany(一对多)
- Price.Quote > 参考资料(多对一)
- Price.Carrier > 参考资料(一对一)