摘要:LINQ to Entities
Linq to Entities 總匯 by http://www.dotblogs.com.tw/asdtey/Tags/Linq%20to%20Entities/default.aspx
取每頁要顯示的資料
entities.Roles.OrderBy(u => u.ID).Skip(startRowIndex).Take(maximumRows);
Left join by http://blog.miniasp.com/post/2010/10/14/LINQ-to-SQL-Query-Tips-INNER-JOIN-and-LEFT-JOIN.aspx
from c in Categories
join o in Products on c.CategoryID equals o.CategoryID into ps
from o in ps.DefaultIfEmpty()
select new { c.CategoryName, o.ProductName }
欲組合不同欄位時
例:BandWidth = SqlFunctions.StringConvert(a.BandWidth) + d.UnitName
模糊查詢 by http://social.msdn.microsoft.com/Forums/zh-tw/5a5b8064-0536-4847-b12f-4a7f11f91143/linqsql?forum=232
Where p.橋樑名稱.Contains("雲林")
多條件查詢 by http://www.dotblogs.com.tw/asdtey/archive/2009/09/30/10837.aspx
07 |
var users = te.user.Select(a => a); |
08 |
|
09 |
if (! string .IsNullOrEmpty(TextBoxId.Text)) |
10 |
{ |
11 |
int id = int .Parse(TextBoxId.Text); |
12 |
users = users.Where(a => a.user_id == id); |
13 |
} |