2009-12-30

LINQ 查日期區間 between 日期 From to 使用VB.NET

昨天遇到一個要使用到LINQ查日期區間的程式

原來就是這麼簡單!
直接來看Code吧!抄回去就能用了



Using db As New TestClassesDataContext()

Dim query = From p in db.Test _
Where p.CreateDt >= CType(dt_Date_From.Value, DateTime) _
And p.CreateDt 〈 DateAdd(DateInterval.Day, 1, CType(dt_Date_To.Value, DateTime)) _
Select p
End Using


搞定~收工

0 comments: