1
我有一個關於存儲庫訪問位置的問題。允許或包含Repository維護的實體內的Repository訪問是否可接受?與存儲庫模式的關注分離
例如:
class Product
{
public int ProductID {get;set;}
public int Name {get;set;}
public IList<Product> Products {get;set;} // A Product may be a bulk item that contains several individual items.
public int VendorID {get;set;} // Key to another table that list vendor info.
}
public class ProductRepository : IRepository
{
public Product GetProduct(int id) {}
public IList<Product> GetProducts() {}
}
幾個問題:
- 應該在哪裏檢索來自其它表的信息放置在何處?倉庫,服務,實體等。這也適用於散裝物品的包含產品?
- 什麼時候應該發生這種情況,在檢索產品時,或者供應商/子產品訪問時?
感謝您的快速響應。我已經看過NHibernate,但是,它看起來有一些學習,以實現。我正在研究的這個項目真的是用於練習。我對使用NHibernate有一段時間感興趣,或許現在是時候潛入。 – Neal
@Neal:您的問題表明您正在查看ORM提供的答案的確切方向,所以我認爲您很可能在調查Hibernate會給你最大的結果的正確點。 –