我有一個跨層,Widget的業務層對象。我希望它在不同的圖層中公開一組不同的屬性。下面是如果編譯器閱讀評論它會怎樣看:圖層的可訪問性不能通過組裝
//bl.dll
public abstract class Widget
{
//repo only
internal virtual Ppty_A {get;set;} //internal to implementation assembly of repo
//repo and service only
internal virtual Ppty_B {get;set;} //internal to implementation assemblies of repo/svc
//everyone inlcuding presentation
public virtual Ppty_C {get;set;}
}
public interface IWidgetService
{ ... } }
public interface IWidgetRepo
{ ... }
public class SimpleWidgetService : IWidgetService
{ ... }
//dal.dll
using bl;
public WidgetRepo
{ ... }
//presentation.dll
using bl;
public WidgetController
{
public WidgetController(IWidgetService ...)
...
}
我的想法是這樣做(我沒有測試過這又和它只是解決了問題的一半):
//bl.dll
public abstract class Widget
{
//repo only simply can't be defined in the abstraction -- can't see you => no contract
//repo and service only has to be public?
public virtual Ppty_B {get;set;}
//at least public is public...
public virtual Ppty_C {get;set;}
}
//dal.dll
using bl;
public SQLWidget : Widget //Or actually DALBLWidget -- see below?
{
//repo only
internal ...
internal ...
//the rest
...
}
我應該創建另一個抽象的Widget(有一個DAL-BL Widget和一個BL-UI Widget)?
你爲什麼要這個設計?爲每個圖層定製DTO並不是一個更好的主意,只需要傳遞所需的數據? – 2012-04-15 19:30:00
我不知道有一個很好的選擇,當我不得不進行更改時,無痛地更新整個「列」。我的直覺是儘量減少代表同一實體的類型的數量(我希望只需要一個,對於ORM) – 2012-04-16 03:24:22
通過更新整列來表示什麼意思? – 2012-04-16 07:13:21