Get the App
SLTechnology News&Howtos  ›  Development  › 

What are the methods of basic operation of LINQ

Shulou Source: shulou.com Published: 2022-06-02 08:58:31 10月03日 Update

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!

Tags: Basic operation learning method code content name that is ideas situations articles more knowledge knowledge points articles follow questions practice push update generate Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Shulou Tech Info MySQL Microsoft Huawei