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