2009-06-09 53 views
2

域:(流利)NHibernate的字典映射與類重點

class Category 
    string Name 
class Product 
    IDictionary<string, Product> Parents 

表:

Categories (ID, Name) 
    Products (ID) 
    ProductParents (ID, ParentID, ChildID, CategoryID) 

的問題:我需要得到家長的產品清單。是否有可能將父母產品映射到字典,以便我可以這樣做: product.Parents [「CategoryName」] 它會給我一個給定類別的父級產品列表。

或許

product.Parents[Category("CategoryName")] 

如果我使用

IDictionary<Category, Product> Parents 

或者我該怎麼做呢?也許像product.GetParentProducts(字符串類)而不是屬性的方法?不過,我寧願使用字典。

請注意,我並不想介紹ProductMapping類。

回答

1

這可能與NHibernate;你在找什麼叫做ternary association

這是目前在流利NHibernate中不可用,但我正在努力添加它。然而,由於FNH正在進行「replumbing」,它可能還有一段時間還不能使用。您最好的選擇可能是使用標準的HBM文件進行此映射。

如果你想進一步研究在FNH中做什麼(注意:你必須保留你自己的本地庫的副本),你可以看到我做了什麼at github

+0

謝謝指出。但是,據我所見,這是可用的,作爲http://code.google.com/p/fluent-nhibernate/issues/detail?id=226的一部分進行了修正,並已集成到http://code.google的.com/p /流利-的nhibernate /源極/細節?R = 524。我將獲取並測試最新版本。 – queen3 2009-06-10 15:13:22