これが私のドメインの3つのクラスです:
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<[匿名オブジェクト]>である必要があります。ルートドメインオブジェクトであるため、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(1対多)
- Price.Quote>参照(多対1)
- Price.Carrier>参照(1対1)