c# - NHibernate QueryOver get time from datetime property -
i'm saving both date , time datetime
in sql server database, , have datetime
property in mappings. in query need access date individually , time well. date have no problem when trying time datetime following error:
additional information: not resolve property: timeofday of: iws.datacontracts.servicesplanning
saving time in other property not want though tried , can't working either.
query queryover
:
session.queryover<servicesplanning>() .joinalias(x => x.teammember, () => stm) .where(() => stm.id == _memberid) .where(x => (x.allday && (x.startdate == _startdate && x.enddate == _enddate)) || (!x.allday && x.startdate.date == _startdate && x.enddate.date == _enddate && (x.startdate.timeofday > _endtime.value || x.enddate.timeofday < _starttime.value))) .rowcount() > 0;
query linq:
return session .query<servicesplanning>() .where(x => x.teammember.id == _memberid) .any(x => (x.allday && (x.startdate.date == _startdate && x.enddate.date == _enddate)) || (!x.allday && x.startdate.date == _startdate && x.enddate.date == _enddate && (x.startdate.timeofday > _endtime.value || x.enddate.timeofday < _starttime.value)));
purpose of query: check if there planning date or time don't have overlaps.
any appreciated!
instead of trying manipulate what's in database comparison, why don't adjust parameter?
if database contains example 2016-01-01t08:00:00
date, , want query records date on 2016-01-01
regardless of time, can query date "between" 2016-01-01t00:00:00
, 2016-01-01t23:59:59
, so:
.where(x => (x.allday && (x.startdate == _startdate && x.enddate == _enddate)) || (!x.allday && x.startdate >= _startdate.date && x.startdate < _startdate.date.adddays(1))...
Comments
Post a Comment