[请教]这句SQL查询,LINQ怎么实现

Xuon 2010-07-21 07:14:33
select updateagaintime=(case  when updateagaintime is null then begintime  else updateagaintime end)
from workplan


SQL如上,对应的LINQ怎么写?
...全文
104 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
阿非 2010-07-22
  • 打赏
  • 举报
回复
好,谢谢分享。

linq to sql 我没用过,有机会试一下。
Xuon 2010-07-22
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 sandy945 的回复:]

如果是多个的话,看这个链接

http://topic.csdn.net/u/20090729/10/2788617f-0b6e-4773-831b-340bf2bfd9c5.html?1091008305
[/Quote]

跟你分享一下,我昨天这么用遇到的问题。
错误提示“不允许在查询中显式构造实体类型”。

换了老赵的方法:http://jeffz.blog.51cto.com/309226/62391
结果集用的IQueryable类型的,查询了很多次,错误提示为“无法枚举查询结果多次”。

ToList之后就没问题了:
http://www.59jc.com/csharpjc/20100407/631285779579.html
阿非 2010-07-21
  • 打赏
  • 举报
回复
Xuon 2010-07-21
  • 打赏
  • 举报
回复
额,给分。
Xuon 2010-07-21
  • 打赏
  • 举报
回复
from w in workplan
select new workplan
{
updateagaintime=w.updateagaintime==null?w.begintime:w.updateagaintime
};


额,貌似是这样子。
试出来了。
阿非 2010-07-21
  • 打赏
  • 举报
回复
var query = from c in workplan select new { updateagaintime = c.updateagaintime==null ? c.begintime : c.updateagaintime };

8,497

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 LINQ
社区管理员
  • LINQ
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧