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}