查询C#中的Linq datetime日期匹配 [英] Linq datetime date match in query c#

查看:543
本文介绍了查询C#中的Linq datetime日期匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试匹配Datetime.现在是唯一的年份(例如今天是2014年).但是,我无法通过使用datetime.now的年份在linq查询中进行操作.

I am trying to match Datetime.Now's only year(as instance Today is 2014).However i could not do inside of linq query by using datetime.now's year.

LevyServiceHelper.GetAllLevyFee().
List.Where(s=>s.ValidDate==Datetime Today Year).ToList();

如何将Datetime Today Year与s.ValidDate匹配?

How can i match Datetime Today Year with s.ValidDate ?

谢谢.

推荐答案

LevyServiceHelper.GetAllLevyFee().
List.Where(s=>s.ValidDate.Year == DateTime.Today.Year).ToList();

这篇关于查询C#中的Linq datetime日期匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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