我有一个CustomerRepository类(在我的BL),和我返回集合如下:定制收集问题
public static ICollection<Customer> FindCustomers()
{
Collection<Customer> customers = null;
try
{
customers = DAL.GetCustomers();
}
catch (Exception ex)
{
//log and re-throw exception here
}
return customers;
}
我有这几个问题:
- 是try/catch块好吗?
- 我在外面尝试创建集合,并将其返回外部。
我可以忽略这里的任何最佳实践吗?
很想知道这里潜在的陷阱:)
只是一个评论,为什么ICollection而不是IQueryable。顺便说一句,在TRY – StevenMcD 2009-08-04 08:52:47