我有两种方法,不喜欢重复:
public Order LatestOrderOver(decimal amount)
{
return session.QueryOver<Order>()
.Where(o => o.Amount > amount)
.OrderBy(sr => sr.CompleteUtcTime).Desc
.Take(1)
.SingleOrDefault<Order>();
}
public Order LatestAmericanOrderOver(decimal amount)
{
return session.QueryOver<Order>()
.Where(o => o.Amount > amount && o.Country == "USA")
.OrderBy(sr => sr.CompleteUtcTime).Desc
.Take(1)
.SingleOrDefault<Order>();
}
当您在 QueryOver 中使用类似的标准(在 Where 子句中)和最后的类似选项时,避免重复的最佳方法是什么?