Dapper is a lightweight ORM library, dapperorm
Reading
http://stackexchange.github.io/dapper-dot-net/
https://github.com/StackExchange/dapper-dot-net
https://msdn.microsoft.com/zh-cn/magazine/mt703432.aspx
Reference
You can download it directly through Nuget. If you need the source code, you can download it through git. The above link is provided.
Basic operations
A simple mssql data table is defined.
Private static List <Student> Read () {using (var connect = new SqlConnection (connectionString) {connect. open (); var query = connect. query <Student> ("select top 1000 [Id], [Name], [Grade] FROM [TESTDB]. [dbo]. [Student]; "); return query. toList () ;}} private static void Add () {using (var connect = new SqlConnection (connectionString) {connect. open (); var result = connect. execute ("insert into [dbo]. [Student] ([Id], [Name], [Grade]) VALUES (@ Id, @ Name, @ Grade); ", new [] {new {Id = 2, name = "Li Si", Grade = 1}, new {Id = 3, Name = "Wang Wu", Grade = 1}, new {Id = 4, name = "Zhao six", Grade = 1}); Console. writeLine ("affected rows {0}", result) ;}} private static void Update () {using (var connect = new SqlConnection (connectionString) {connect. open (); var result = connect. execute ("UPDATE [dbo]. [Student] SET [Grade] = @ Grade WHERE Id = @ Id; ", new {Id = 2, Grade = 2}); Console. writeLine ("affected rows {0}", result) ;}} private static void Delete () {using (var connect = new SqlConnection (connectionString) {connect. open (); var result = connect. execute ("delete from [dbo]. [Student] WHERE Id = @ Id; ", new {Id = 1}); Console. writeLine ("affected rows {0}", result );}}