参考 :https://www.jianshu.com/p/c4ca2989d26a
仍有很多其他复杂操作,Dapper真好使
CREATE TABLE [dbo].[Books] (
[BookId] INT NOT NULL,
[Publisher] NVARCHAR (30) NULL,
[Title] NVARCHAR (50) NOT NULL,
CONSTRAINT [PK_Books] PRIMARY KEY CLUSTERED ([BookId] ASC)
);
using Dapper;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
namespace WpfApp16
{
class Book
{
public int BookId{
get; set; }
public string Publisher {
get; set; }
public string Title {
get; set; }
public Book(int id,string pub,string title)
{
this.BookId = id;
this.Publisher = pub;
this.Title = title;
}
public Book()
{
this.BookId = 0;
this.Publisher = "ss";
this.Title = "233";
}
}
class BooksDB
{
private static readonly string connectionString