如何在Ef或Linq中更改此Sql查询 [英] How I Can Change This Sql Query In To Ef Or Linq

查看:75
本文介绍了如何在Ef或Linq中更改此Sql查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的查询

从中选择*  EmployeeStatus es  where 不存在
选择 * 来自 RouteSectorStatus rS WHERE es。 Employee_Id = rS.Employee_Id AND RouteSectorStatusDate = ' 2015-05-20'



如果

已经用完的员工再也不能用完了,那么剩下的员工将被分配给下一个功能同一天。

这个查询功能正常但我想更改那个查询使用EF或LINQ

解决方案

这样的事情应该有效:

  var  theDate =  new  DateTime ( 2015  5  20 ); 

var data = context.EmployeeStatuses.Where(
es = > !context.RouteSectorStatuses.Any(
rs = > rs.Employee_Id == es.Employee_Id&& rs.RouteSectorStatusDate == theDate ));


THIS IS my QUERY

Select * from EmployeeStatus es where Not exists 
(select * from RouteSectorStatus rS  WHERE es.Employee_Id=rS.Employee_Id AND RouteSectorStatusDate='2015-05-20')


IF employee that
are already used up can never used up again,rather employee that are
left behind are allocated for next function for the same day.
THIS query is function properly but i want to change that query Using EF OR LINQ

解决方案

Something like this should work:

var theDate = new DateTime(2015, 5, 20);

var data = context.EmployeeStatuses.Where(
    es => !context.RouteSectorStatuses.Any(
        rs => rs.Employee_Id == es.Employee_Id && rs.RouteSectorStatusDate == theDate));


这篇关于如何在Ef或Linq中更改此Sql查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆