Hello guys, I have an application and I'm trying to implement DDD concepts.
I have my repository class with some method to list entities. I would like
to know how can I do a query with QueryOver to filter separating with 'AND'
operator, when the parameter is filled, sample

public IEnumerable<Product> FindProducts(string name, decimal? price,
DateTime? validDate, int? stock, int? idSupplier)
{
   var query = Session.QueryOver<Product>().OrderBy(x => x.Name).Asc;

   if (!string.IsNullOrEmpty(name))
      // add where condition for name parameter

   if (price.HasValue)
      // add 'AND' where condition for price parameter

   if (validDate.HasValue)
      // add 'AND' where condition for validDate parameter

   if (idSupplier.HasValue)
      // add 'AND' where condition for idSupplier parameter

   // other possible conditions

   return query.List();
}


Thank you

-- 
______________________________________
Felipe B. Oriani
felipeoriani.com.br [email protected]
@felipeoriani<http://www.twitter.com/felipeoriani>
 LinkedIn <http://br.linkedin.com/in/felipeoriani>
Facebook<http://www.facebook.com/felipeoriani>
Contato: (19) 9611-8646 / (19) 3421-7850

"...Trabalhe quanto puder, tornando-se útil quanto possível..." , por André
Luiz

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to