Webform LinQ, webformlinq

Source: Internet
Author: User

Webform LinQ, webformlinq

Language Integrated Query is a set of extensions for c # and VB languages. It allows you to write C # Or Visual Basic code to query memory data in the same way as a database.

He is an integrated data classification class. Microsoft will automatically generate some code that we originally needed to write and integrate into this class.

 

Database Data Access

 

What is the difference with ADO. NET? There is no difference, that is, the amount of code is reduced.

 

Create a UDF:

Add new item:

 

 

Connect to database

 

Query by LinQ:

 

Query all and conditional Lamdba expressions

 

Add, delete, and modify

1 using System; 2 using System. collections. generic; 3 using System. linq; 4 using System. web; 5 6 /// <summary> 7 // UsersData abstract description 8 /// </summary> 9 public class UsersData10 {11 Data0617DataContext con = new Data0617DataContext (); 12 13 public void Insert (Users u) 14 {15 con. users. insertOnSubmit (u); 16 con. submitChanges (); 17} 18 19 public void Delete (string Uname) 20 {21 Users uu = con. users. where (r => R. UserName = Uname). FirstOrDefault (); 22 if (uu! = Null) 23 {24 con. users. deleteOnSubmit (uu); 25 con. submitChanges (); 26} 27} 28 29 public Users Select (string uname) 30 {31 return con. users. where (r => r. userName = uname ). firstOrDefault (); 32} 33 34 public void Update (Users u) 35 {36 Users uuu = con. users. where (r => r. userName = u. userName ). firstOrDefault (); 37 uuu. passWord = u. passWord; 38 uuu. nickName = u. nickName; 39 uuu. sex = u. sex; 40 uuu. birthday = u. birthday; 41 uuu. nation = u. nation; 42 con. submitChanges (); 43} 44 45 46}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.