1
假設我有具有象需要有關訪問數據庫
public Comment GetComment(Guid id)
而且
public static List<Comment> GetComments()
public static List<Comment> GetCommentsByAuthor(Author id)
現在,我最常做的是寫的數據庫邏輯屬性和他們的方法 評論類的建議上述方法中的每個 。 這就是說,現在我看到BlogEngine.NET代碼和他在這個 方式中寫道; 他使用類似
//FindAll is a method in List<T> class
FindAll(delegate(Comment comment)
{
return comment.Author.Equals(author ,
StringComparison.OrdinalIgnoreCase);
}
);
我的問題是,寫的數據庫邏輯GetComments()方法,並從中提取 所有剩餘的方法,即使是GetComment(GUID ID)由 ,它是一個好主意這樣做而不是 第一種方法? 這種方式的任何優點和缺點,建議和指針和 資源是最受歡迎的。 TIA Srinivas