开发者

Select only Saturdays data from date range

开发者 https://www.devze.com 2023-03-27 22:34 出处:网络
I need to b开发者_StackOverflow中文版e able to display data for all date range and for the same date range but only for Saturdays.

I need to b开发者_StackOverflow中文版e able to display data for all date range and for the same date range but only for Saturdays.

Data stored in sql server.

Table:
DateTime  Vlaue

Is it possible to create linq to sql query which would do that? Or just select all for particular range and than on server side find all Saturdays?

What is the better way to do that?


You should be able to do something like this:

var results = Entities.YourTable.Where(r => r.SomeDate.DayOfWeek == DayOfWeek.Saturday);


I'd be inclined to just query the database once, then use linq to objects on the result set for the saturday data...

var values = db.Values.ToList(); // assuming your table is called values
var satValues = values.Where( v => v.TheDate.DayOfWeek == DayOfWeek.Saturday);
0

精彩评论

暂无评论...
验证码 换一张
取 消