Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the methods of basic operation of LINQ

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "what are the methods of the basic operation of LINQ". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn what are the basic operation methods of LINQ.

LINQ basic operation learning 1.

I first create a table named: userinfo.

LINQ basic operation learning 2.

Pull the table onto the linq file of vs 2008, and then save it, and you will see that ms uses the drag-and-drop method to generate the corresponding class of the table, which is much more convenient than nhibername. As soon as you save it, it will automatically become a class.

LINQ basic operation learning 3. Write code:

The basic operation code of LINQ is as follows:

Public partial class TestLinQ_Default: System.Web.UI.Page. {GetUserInfoDataContext cxt = new GetUserInfoDataContext (System.Configuration.ConfigurationManager. ConnectionStrings ["TestConnectionString"]. ToString (); protected void Page_Load (object sender, EventArgs e). {} / / LINQ basic operation insertion operation protected void Button1_Click (object sender, EventArgs e) en_Text'') .style.display =''inline''; "align=" top "alt="src=" http://images.csdn.net/syntaxhighlighting/ OutliningIndicators/ContractedSubBlock.gif "/ >. {UserInfo userinfo = new UserInfo (); userinfo.username = TextBox1.Text Userinfo.password = TextBox2.Text; cxt.UserInfos.InsertOnSubmit (userinfo); cxt.SubmitChanges (); / / cxt.InsertUserInfo (TextBox1.Text, TextBox2.Text);} / / deletion of basic LINQ operations protected void Button2_Click (object sender, EventArgs e). {UserInfo userinfo = cxt.UserInfos.Single (b = > b.id = = int.Parse (txt_id.Text)); cxt.UserInfos.DeleteOnSubmit (userinfo); cxt.SubmitChanges () } / / the update operation protected void Button3_Click (object sender, EventArgs e) splay=''inline''; document.getElementById for the basic operation of LINQ ('_ 947, 1210 Closedholders Textbacks'). Style.display=''inline''; "align=" top "alt="src=" http://images.csdn.net/syntaxhighlighting/ OutliningIndicators/ExpandedSubBlockStart.gif "/ >. {UserInfo userinfo = cxt.UserInfos.Single (b = > b.id = = int.Parse (txt_update_id.Text)); userinfo.username = txt_update_username.Text; userinfo.password = txt_update_password.Text; / / cxt.UserInfos. Cxt.SubmitChanges ();}} Thank you for your reading. The above is the content of "what are the basic operation methods of LINQ?" after the study of this article, I believe you have a deeper understanding of what the basic operation methods of LINQ have, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report