c# 4.0 - NHibernate queryover how to apply date isbetween without including the from and todate -
i trying write nhibernate queryover select records has been deleted between 2 dates. using isbetween().and(). how write if dont want include both fromdate , todate?
here query:
public ienumerable<deletedrecord> search( datetime deletedfrom, datetime deletedto ) { deletedrecord delalias = null; var query = session.queryover(() => delalias); query.where(() => delalias.deleteddate.isbetween(deletedfrom).and(deletedto)); return query.future<deletedrecord>(); }
can me how achieve can bring records after deletedfrom date , before deletedto date?
thanks
just construct date in 2 steps:
var query = session.queryover(() => delalias); if(youneedfromdate) //first step query = query.where(() => delalias.deleteddate >= deletedfrom); if(youneedtodate) //second step query = query.where(() => delalias.deleteddate <= deletedto);
youneedfromdate
, youneedtodate
bool
variables can pass function or different condition upon logic.
Comments
Post a Comment