[英]Entity Framework repository Pattern Inheritance
class A
{
public int id {get; set;}
}
class B : A
{
}
class C : A
{
}
現在,對於B和C擁有一個單獨的存儲庫是有意義的,還是應該將類型信息傳遞給A的存儲庫中的方法,然后從那里返回內容。
class ARepository : RepositoryBase<Context>,IARepository
{
A GetById (int id )
{
//some linq query here
}
//should this be here or in a separate repository
A GetBByID (int id)
{
}
}
我選擇另一個存儲庫的原因是如果我想要
class D : A
or Class E : C
這可能開始變得混亂和棘手。
那么最好的方法是什么?
我更喜歡每個EntityFramework Context具有一個大型存儲庫,從而簡化了維護。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.