如何在EF 3.5中编写 [英] How to write in EF 3.5

查看:95
本文介绍了如何在EF 3.5中编写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在EF 3.5查询中编写以下条件.下面是SQL格式.

How to write below condition in EF 3.5 Query. Below in SQL format.

a.member in ('Free','PartTime') and (DATEDIFF(m,asofdate,getdate())>0 or AsOfDate is null)

推荐答案

您正在使用的LINQ.使用DateTime.Now获取当前日期,然后从那里进行比较.您知道如何编写LINQ查询吗?
It''s LINQ you are using. use DateTime.Now to get the current date, and then compare it from there. Do you know how to write LINQ queries ?


看看 http://www.linqpad.net / [^ ]

LINQPad允许您使用linq交互式地查询数据库-这是用于尝试查询的有用工具.

我也很确定我会使用 ExecuteStoreQuery [
Have a look at http://www.linqpad.net/[^]

LINQPad lets you interactively query databases using linq - it''s a useful tool for trying out queries.

I''m also pretty certain that I would use ExecuteStoreQuery[^] and just execute the query using your SQL.

I expect that you know that your query will be translated back to SQL because SQL server hasn''t got a clue about linq.

Best regards
Espen Harlinn


这篇关于如何在EF 3.5中编写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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