これが私のドメイン モデルの小さな抜粋です。
public class Chain
{
public IList<Product> Products { get; set; }
}
public class Store
{
public Chain Chain { get; set; }
public IList<Product> Products { get; set; }
}
Productここで、Store および関連する でクエリを作成する必要がありますChain。問題は、所有物に保管されている製品のクエリをどのように拡張できるChainかです。
これが私がこれまでに持っているものです:
var subQuery = QueryOver.Of<Store>()
.Where(s => s.Id == searchCriteria.StoreId)
.Select(s => s.Id);
Store storeAlias = null;
var query = _session.QueryOver<Product>()
.JoinAlias(p => p.Stores, () => storeAlias)
.WithSubquery.WhereProperty(() => storeAlias.Id).In(subQuery);
//// some more clauses...
これどうやってするの?注意:Chainのプロパティは であるStore可能性がありますnull。