Dapper

Posted by Leo Yang on 2020-07-02

使用Dapper,不要自己刻ORM

nuget搜尋、安裝Dapper
using Dapper
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
public IEnumerable<dynamic> ExecQuery(string query)
{
try
{
ConnectionString = $"Data Source = {server}; Initial Catalog = {DB}; User ID = {userID}; Password ={password}";
conn.Open();
result = conn.Query(query);
return result;
}
catch (Exception ie)
{
//do nothing,make AOP exceptions everywhere.
}
finally
{
conn.Close();
}
return null;
}