我正在数据库中存储员工的休假信息。从和到日期将存储在数据库中。我想阻止员工在已申请的休假范围内申请休假。
例如:假设一名员工已在 01/01/2015 至 05/01/2015 之间申请休假,
i)if user again try to apply leave for 04/01/2015 to 07/01/2015,then i need to block that one.
ii)if user again try to apply leave for 05/01/2015 to 05/01/2015,then i need to block that one.
我如何使用 Linq 查询找到它
你可以尝试如下
return (from t1 in db.Employee where ( empid == t1.EmplyeeId &&
date1 >= t1.LeaveStart && date2 <= t1.LeaveEnd))
您可以尝试如下,详细答案
int cntleaves = (from values in dbcontext.User_master
where values.iUser_id == Userid &&
((values.dtStart_date >= Startdate &&
values.dtEnd_date <= Enddate)
||
(values.dtStart_date <= Startdate &&
values.dtEnd_date <= Enddate))
select values).ToList().Count();
if (cntleaves > 0) {
ViewBag.Message = "You have already applied for leaves !";
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)