c 封裝Dapper操作類

2022-01-12 15:12:32 字數 3750 閱讀 3549

using

using

using

system.collections.generic;

using

system.configuration;

using

system.data;

using

system.data.sqlclient;

using

system.linq;

using

system.threading.tasks;

namespace

dblibrarys.dbhelper

public

static

sqlconnection getopenconnection()

//////

執行sql返回乙個物件

/// ///

//////

//////

public

static t executereaderreturnt(string sql, object param = null, bool usewriteconn = false, idbtransaction transaction = null

)

}else

}//////

執行sql返回多個物件

/// ///

//////

//////

public

static listexecutereaderreturnlist(string sql, object param = null, bool usewriteconn = false, idbtransaction transaction = null

)

}//////

執行sql返回乙個物件--非同步

/// ///

//////

//////

public

static

async taskexecutereaderrettasync(string sql, object param = null, bool usewriteconn = false

)

}//////

執行sql返回多個物件--非同步

/// ///

//////

//////

public

static

async task> executereaderretlistasync(string sql, object param = null, bool usewriteconn = false

)

}//////

執行sql,返回影響行數

/// ///

//////

///public

static

int executesqlint(string sql, object param = null, idbtransaction transaction = null

)

}else

}//////

執行sql,返回影響行數--非同步

/// ///

//////

///public

static

async task executesqlintasync(string sql, object param = null, idbtransaction transaction = null

)

}else

}//////

根據id獲取實體

/// ///

//////

//////

public

static t getbyid(int id, idbtransaction transaction = null, bool usewriteconn = false) where t : class

}else

}//////

根據id獲取實體--非同步

/// ///

//////

//////

public

static

async taskgetbyidasync(int id, idbtransaction transaction = null, bool usewriteconn = false) where t : class

}else

}//////

插入實體

/// ///

//////

///public

static

string executeinsert(t item, idbtransaction transaction = null) where t : class

}else

}//////

批量插入實體

/// ///

//////

public

static

void executeinsertlist(ienumerablelist, idbtransaction transaction = null) where t : class

}else

}//////

更新單個實體

/// ///

//////

///public

static

bool executeupdate(t item, idbtransaction transaction = null) where t : class

}else

}//////

批量更新實體

/// ///

//////

///public

static

bool executeupdatelist(listitem, idbtransaction transaction = null) where t : class

}else

}//////

分頁查詢

/// ///

///主sql 不帶 order by

///排序內容 id desc,add_time asc

///第幾頁 ///

每頁多少條

///是否主庫

///public

static listexecutepagelist(string sql, string sort, int pageindex, int pagesize, bool usewriteconn = false, object param = null

) * from (select row_number() over (order by ) _row_number_,* from

()temp )temp1 where temp1._row_number_> order by _row_number_";

string execsql = string.format(pagesql, pagesize, sort, sql, pagesize * (pageindex - 1

));

using (idbconnection conn =getconnection(usewriteconn))}}

}

C 封裝Word常用操作類

object nullobj system.reflection.missing.value microsoft.office.interop.word.document doc word.documents.open ref filename,ref nullobj,ref nullobj,ref...

C 工具類 FTP操作封裝類FTPHelper

c ftphelper實現ftp伺服器檔案讀寫操作,支援ssl協議 ftp伺服器為 serv u10.0 using system using system.collections.generic using system.io using system.linq using system.net ...

redis操作封裝類

class redis 設定redis配置 執行前,配置會被重置為 host port 6379 access public param array conf 配置檔案集合,包含引數 string host 伺服器位址 string port 伺服器端口 return void public fun...