日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
LINQtoSQL動態(tài)查詢概括

LINQ to SQL有很多值得學(xué)習(xí)的地方,這里我們主要介紹LINQ to SQL動態(tài)查詢,包括介紹LINQ to SQL功能和調(diào)試特定等方面

LINQ to SQL動態(tài)查詢

使用LINQ to SQL動態(tài)查詢,這個例子用CreateQuery()方法創(chuàng)建一個IQueryable類型表達(dá)式輸出查詢的語句。

這里給個例子說明一下:

 
 
 
  1. var c1 = Expression.Parameter(typeof(Customer), "c");  
  2. PropertyInfo City = typeof(Customer).GetProperty("City");  
  3.  
  4. var pred = Expression.Lambda, bool>>(  
  5. Expression.Equal(  
  6. Expression.Property(c1, City),  
  7. Expression.Constant("Seattle")  
  8.  ), c1  
  9. );  
  10. IQueryable custs = db.Customers;  
  11. Expression expr = Expression.Call(typeof(Queryable), "Where",  
  12. new Type[] { custs.ElementType }, custs.Expression, pred);  
  13. IQueryable q = db.Customers.AsQueryable().  
  14. Provider.CreateQuery(expr); 

Log屬性用于將SQL查詢或命令打印到TextReader。此方法對了解 LINQ to SQL功能和調(diào)試特定的問題可能很有用。

下面的示例使用Log屬性在SQL代碼執(zhí)行前在控制臺窗口中顯示此代碼。我們可以將此屬性與查詢、插入、更新和刪除命令一起使用。

 
 
 
  1. //關(guān)閉日志功能  
  2. //db.Log = null;  
  3. //使用日志功能:日志輸出到控制臺窗口  
  4. db.Log = Console.Out;  
  5. var q = from c in db.Customers  
  6. where c.City == "London"  
  7. select c;  
  8. //日志輸出到文件  
  9. StreamWriter sw = new StreamWriter(Server.MapPath("log.txt"), true);  
  10. db.Log = sw;  
  11. var q = from c in db.Customers  
  12. where c.City == "London"  
  13. select c;  
  14. sw.Close(); 

新聞標(biāo)題:LINQtoSQL動態(tài)查詢概括
瀏覽地址:http://www.5511xx.com/article/dpjgceo.html