You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
IQuery<T> is meant to replace methods on the repository, and lives in the Tasks Layer. Queries can then be passed down to lower layers to help populate viewModels, reporting or for usage in other applications. The contracts live in the Domain Layer and the implementation lives in the Infrastructure Layer. The convention is one file per query.
Example Implementation
IQuery
// One file per Query
public class ProductsForSaleQuery : NHibernateQuery<Product>, IProductsForSaleQuery
{
public override IList<Product> ExecuteQuery()
{
return (from product in Session.Query<Product>()
where product.SellEndDate.Date > DateTime.Parse("5/30/2003")
select product).ToList();
}
}
Contract
public interface IProductsForSaleQuery : IQuery<Product>
{
}
Tasks
public IList<Product> GetProductsForSale()
{
return this.productRepository.PerformQuery(this.productsForSaleQuery);
}