Dapper

https://www.cnblogs.com/huangxincheng/p/5828470.html

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;
using Dapper;

namespace TestDapper
{
    class Program
    {
        static void Main(string[] args)
        {
            string connectionStr = "Data Source=LJJ-FF\\LJJ;Initial Catalog=TestDapper;User ID=sa;Password=111111;Max Pool Size=500;Min Pool Size=1";
            IDbConnection connection = new SqlConnection(connectionStr);
            //var result1 = connection.Execute("Insert into Users values (@UserName, @Email, @Address)",
            //                     new { UserName = "jack", Email = "380234234@qq.com", Address = "上海" });

            //var usersList = Enumerable.Range(0, 10).Select(i => new Users()
            //{
            //    Email = i + "qq.com",
            //    Address = "安徽",
            //    UserName = i + "jack"
            //});

            //var result2 = connection.Execute("Insert into Users values (@UserName, @Email, @Address)", usersList);

            //var query = connection.Query<Users>("select * from Users where UserName=@UserName", new { UserName = "jack" });
            //if (query != null)
            //{
            //    Console.WriteLine(((Users)query.FirstOrDefault()).UserName);
               
            //}

            //var result3 = connection.Execute("update Users set UserName=‘nancy‘ where UserID=@UserID", new { UserID=11 });
            var result4 = connection.Execute("delete from Users where UserID=@UserID", new { UserID = 10});
            Console.ReadKey();

        }
    }

    class Users
    {
        public string UserID { get; set; }
        public string UserName { get; set; }
        public string Email { get; set; }
        public string Address { get; set; }
    }
}

 

Dapper

上一篇:EscaperWrapper 转义和反转义


下一篇:安卓动画的使用