select *
from qmsCallAudit
where CAST(FLOOR(CAST(callauditdt AS float)) AS DATETIME)
between '2015-07-16 00:00:00' and '2015-07-16 00:00:00'
以上查询在sql查询中返回记录
来自linq的它不起作用,下面是应用程序代码
var query = (
from qd in db.qmsCallAuditDetails
from qm in db.qmsCallAudits
where qm.callaudit_id == qd.callaudit_id &&
qm.active == true
&& qm.process_id == processid
&& fdt >= qm.callauditdt
&& tdt <= qm.callauditdt
select qd
).AsQueryable();
string semp = frm["employee_id"];
if (semp.Length > 0)
{
int empid = Convert.ToInt32(frm["employee_id"]);
query = query.Where(q => q.qmsCallAudit.employee_id==empid);
}
以上linq查询的SQL配置文件代码
exec sp_executesql N'SELECT
[Extent1].[callauditdetail_id] AS [callauditdetail_id],
[Extent1].[callaudit_id] AS [callaudit_id],
[Extent1].[subparameter_id] AS [subparameter_id],
[Extent1].[subparameterdisp_id] AS [subparameterdisp_id],
[Extent1].[score] AS [score],
[Extent1].[weightage] AS [weightage],
[Extent1].[fatal] AS [fatal],
[Extent1].[add_to_weightage] AS [add_to_weightage],
[Extent1].[auditstatus] AS [auditstatus],
[Extent1].[auditscore] AS [auditscore],
[Extent1].[auditweightage] AS [auditweightage],
[Extent1].[auditremark] AS [auditremark],
[Extent1].[createdon] AS [createdon],
[Extent1].[createdby] AS [createdby],
[Extent1].[modifiedon] AS [modifiedon],
[Extent1].[modifiedby] AS [modifiedby],
[Extent1].[active] AS [active]
FROM [dbo].[qmsCallAuditDetail] AS [Extent1]
INNER JOIN [dbo].[qmsCallAudit] AS [Extent2] ON [Extent2].[callaudit_id] = [Extent1].[callaudit_id]
WHERE (1 = [Extent2].[active]) AND ([Extent2].[process_id] = @p__linq__0) AND (@p__linq__1 >= [Extent2].CAST(FLOOR(CAST(callauditdt AS float)))[callauditdt]) AND (@p__linq__2 <= [Extent2].[callauditdt])',N'@p__linq__0 int,@p__linq__1 datetime2(7),@p__linq__2 datetime2(7)',@p__linq__0=2,@p__linq__1='2015-07-16 00:00:00',@p__linq__2='2015-07-16 00:00:00'
答案 0 :(得分:0)
你的错误是什么?你的ftd和tdt已经是dateTime对象吗?