偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

學(xué)習(xí)LINQ基本操作的一點(diǎn)體會(huì)

開(kāi)發(fā) 后端
學(xué)習(xí)LINQ基本操作其實(shí)就是學(xué)習(xí)LINQ的插入、刪除以及更新的相關(guān)操作,那么具體的實(shí)現(xiàn)以及需要注意的是什么呢?那么本文就向你介紹詳細(xì)的內(nèi)容。

學(xué)習(xí)LINQ基本操作 ,其實(shí)主要就是LINQ更新、插入以及刪除的相關(guān)操作,那么具體的實(shí)現(xiàn)過(guò)程是什么呢?我們?cè)诰唧w的過(guò)程中需要注意什么呢?網(wǎng)上有很多資料,這里向你介紹一些,希望對(duì)你有所幫助。

LINQ基本操作學(xué)習(xí)1.

我首先創(chuàng)建一個(gè)表,名字為:userinfo的表。

userinfo表 

LINQ基本操作學(xué)習(xí)2.

將表拉到vs 2008的linq file上面,然后保存一下,你會(huì)看到如下圖,ms利用拖放式方法,生成表對(duì)應(yīng)的類(lèi),這個(gè)比nhibername方便多了。只要你一保存它就會(huì)自動(dòng)自成一個(gè)class。

自動(dòng)自成一個(gè)class  

LINQ基本操作學(xué)習(xí)3.編寫(xiě)代碼:

實(shí)現(xiàn)效果 

LINQ基本操作代碼如下:

  1. public partial class TestLinQ_Default : System.Web.UI.Page  
  2. ...{  
  3. GetUserInfoDataContext cxt =   
  4.  new GetUserInfoDataContext(  
  5.  
  6. System.Configuration.ConfigurationManager.  
  7.  
  8. ConnectionStrings["TestConnectionString"].ToString());  
  9. protected void Page_Load(object sender, EventArgs e)  
  10. ...{  
  11.  
  12. }  
  13. //LINQ基本操作插入操作  
  14. protected void Button1_Click(object sender, EventArgs e)  
  15. en_Text'').style.display=''inline'';" align="top" alt=""   
  16.  
  17. src="http://images.csdn.net/syntaxhighlighting/  
  18.  
  19. OutliningIndicators/ContractedSubBlock.gif" />...{  
  20.  
  21. UserInfo userinfo = new UserInfo();  
  22. userinfo.username = TextBox1.Text;  
  23. userinfo.password = TextBox2.Text;  
  24.  
  25. cxt.UserInfos.InsertOnSubmit(userinfo);  
  26. cxt.SubmitChanges();  
  27.  
  28.  
  29.   //  cxt.InsertUserInfo(TextBox1.Text, TextBox2.Text);  
  30.     
  31. }  
  32. //LINQ基本操作之刪除操作  
  33. protected void Button2_Click(object sender, EventArgs e)  
  34. ...{  
  35. UserInfo userinfo =   
  36. cxt.UserInfos.Single(b => b.id == int.Parse(txt_id.Text));  
  37. cxt.UserInfos.DeleteOnSubmit(userinfo);  
  38. cxt.SubmitChanges();  
  39. }  
  40. //LINQ基本操作之更新操作protected void Button3_Click(object sender, EventArgs e)  
  41.  
  42. splay=''inline'';   
  43. document.getElementById(''_947_1210_Closed_Text'').  
  44. style.display=''inline'';" align="top" alt="" src=  
  45.  
  46. "http://images.csdn.net/syntaxhighlighting/  
  47.  
  48. OutliningIndicators/ExpandedSubBlockStart.gif" />...{  
  49. UserInfo userinfo =   
  50. cxt.UserInfos.Single(b => b.id ==   
  51. int.Parse(txt_update_id.Text));  
  52. userinfo.username = txt_update_username.Text;  
  53. userinfo.password = txt_update_password.Text;  
  54.  
  55.    // cxt.UserInfos.  
  56. cxt.SubmitChanges();  
  57. }  
  58. }  
  59.  

LINQ基本操作學(xué)習(xí)的一些內(nèi)容就向你介紹到這里,希望對(duì)你了解和學(xué)習(xí)LINQ基本操作有所幫助。

【編輯推薦】

  1. 詳解實(shí)現(xiàn)LINQ to SQL刪除行
  2. C# Lambda Expression概念淺析
  3. 詳解C# Lambda表達(dá)式的動(dòng)態(tài)生成
  4. C# Lambda Expression使用實(shí)例解析
  5. 淺談LINQ刪除XML節(jié)點(diǎn)
責(zé)任編輯:仲衡 來(lái)源: diybl.com
相關(guān)推薦

2009-09-14 20:17:05

并行LINQ

2009-08-27 17:50:09

interface接口

2009-08-13 17:52:13

C#構(gòu)造函數(shù)

2009-09-09 10:53:25

C# MessageB

2009-09-14 19:44:27

LINQ To SQL

2009-08-14 11:29:28

C#創(chuàng)建Windows

2009-08-28 16:30:24

C#線程

2012-07-12 10:49:53

項(xiàng)目管理

2009-08-18 17:34:25

C#操作符重載應(yīng)用

2009-09-03 14:28:23

C#日期格式化

2009-08-04 16:34:13

ASP.NET代碼分離

2010-05-20 15:29:43

優(yōu)化IIS

2009-08-18 17:20:17

C#操作符重載

2009-08-19 11:23:12

C#操作Word

2009-09-17 10:40:23

linq存儲(chǔ)過(guò)程

2009-09-14 10:12:11

LINQ to SQL

2017-04-13 11:20:56

機(jī)器學(xué)習(xí)代碼

2009-06-17 14:36:02

學(xué)習(xí)Java心得

2009-08-19 13:49:14

C#操作注冊(cè)表

2012-03-27 08:49:19

Json
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)