Entity SQL Language六 數字函數、時間函數及其它

函數

數字函數:

db.CreateQuery<double>("Round(1.4)")//四捨五入
db.CreateQuery<double>("Floor(1.9)")//向下取整,即省去小數部分
db.CreateQuery<double>("Ceiling(1.1)")//向上取整,無論小數部分多大都進1

時間函數:

db.CreateQuery("CurrentDateTime()")//獲取當前時間
db.CreateQuery("CurrentUtcDateTime()")//獲取格林威治時間

db.CreateQuery("SELECT o.RequiredDate, Year(o.RequiredDate), Month(o.RequiredDate), Day(o.RequiredDate), Hour(o.RequiredDate), Minute(o.RequiredDate), Second(o.RequiredDate) FROM Orders AS o");//獲取時間的年,月,日,時,分,秒的值

GUID函數:

db.CreateQuery<string>("CAST(NewGuid() as System.String)")//生成一個GUID值

用途:可以利用GUID來進行隨機取數據(即OrderBy NewGuid())

Entity SQL Language的入門知識就介紹到這裏。如果有什麼問題可以給我博客留言。^^

發佈了174 篇原創文章 · 獲贊 5 · 訪問量 60萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章