PetaPoco轻量级ORM框架 - Database API 手册
PetaPoco Database API #region IDisposable
public void Dispose()
#endregion #region Constructors
public Database()
public Database(IDbConnection connection)
public Database(string connectionString, string providerName = null)
public Database(string connectionString, DbProviderFactory factory)
public Database(string connectionStringName)
public Database(string connectionString, IProvider provider, IMapper defaultMapper = null)
public Database(IDatabaseBuildConfiguration configuration)
#endregion #region Connection Management
public bool KeepConnectionAlive;
public void OpenSharedConnection();
public void CloseSharedConnection();
public IDbConnection Connection;
#endregion #region Transaction Management
// Helper to create a transaction scope
public ITransaction GetTransaction()
public virtual void OnBeginTransaction()
public virtual void OnEndTransaction()
public void BeginTransaction()
private void CleanupTransaction()
public void AbortTransaction()
public void CompleteTransaction()
#endregion #region Command Management
private void AddParam(IDbCommand cmd, object value, PropertyInfo pi)
// Create a command
private static Regex rxParamsPrefix = new Regex(@"(?<!@)@\w+", RegexOptions.Compiled);
public IDbCommand CreateCommand(IDbConnection connection, string sql, params object[] args)
#endregion #region Exception Reporting and Logging
public virtual bool OnException(Exception x)
public virtual IDbConnection OnConnectionOpened(IDbConnection conn)
public virtual void OnConnectionClosing(IDbConnection conn)
public virtual void OnExecutingCommand(IDbCommand cmd)
public virtual void OnExecutedCommand(IDbCommand cmd)
#endregion #region operation: Execute
public int Execute(string sql, params object[] args)
public int Execute(Sql sql)
#endregion #region operation: ExecuteScalar
public T ExecuteScalar<T>(string sql, params object[] args)
public T ExecuteScalar<T>(Sql sql)
#endregion #region operation: Fetch
public List<T> Fetch<T>(string sql, params object[] args)
public List<T> Fetch<T>(Sql sql)
#endregion #region operation: Page
public Page<T> Page<T>(long page, long itemsPerPage, string sqlCount, object[] countArgs, string sqlPage, object[] pageArgs)
public Page<T> Page<T>(long page, long itemsPerPage, string sql, params object[] args)
public Page<T> Page<T>(long page, long itemsPerPage, Sql sql)
public Page<T> Page<T>(long page, long itemsPerPage, Sql sqlCount, Sql sqlPage)
#endregion #region operation: Fetch (page)
public List<T> Fetch<T>(long page, long itemsPerPage, string sql, params object[] args)
public List<T> Fetch<T>(long page, long itemsPerPage, Sql sql)
#endregion #region operation: SkipTake
public List<T> SkipTake<T>(long skip, long take, string sql, params object[] args)
public List<T> SkipTake<T>(long skip, long take, Sql sql)
#endregion #region operation: Query
public IEnumerable<T> Query<T>(string sql, params object[] args)
public IEnumerable<T> Query<T>(Sql sql)
#endregion #region operation: Exists
public bool Exists<T>(string sqlCondition, params object[] args)
public bool Exists<T>(object primaryKey)
#endregion #region operation: linq style (Exists, Single, SingleOrDefault etc...)
public T Single<T>(object primaryKey)
public T SingleOrDefault<T>(object primaryKey)
public T Single<T>(string sql, params object[] args)
public T SingleOrDefault<T>(string sql, params object[] args)
public T First<T>(string sql, params object[] args)
public T FirstOrDefault<T>(string sql, params object[] args)
public T Single<T>(Sql sql)
public T SingleOrDefault<T>(Sql sql)
public T First<T>(Sql sql)
public T FirstOrDefault<T>(Sql sql) (关于Linq中First、FirstOrDefault;Single、SingleOrDefault等方法的说明)
#endregion #region operation: Insert
public object Insert(string tableName, object poco)
public object Insert(string tableName, string primaryKeyName, object poco)
public object Insert(string tableName, string primaryKeyName, bool autoIncrement, object poco)
public object Insert(object poco)
private object ExecuteInsert(string tableName, string primaryKeyName, bool autoIncrement, object poco)
#endregion #region operation: Update
public int Update(string tableName, string primaryKeyName, object poco, object primaryKeyValue)
public int Update(string tableName, string primaryKeyName, object poco, object primaryKeyValue, IEnumerable<string> columns)
public int Update(string tableName, string primaryKeyName, object poco)
public int Update(string tableName, string primaryKeyName, object poco, IEnumerable<string> columns)
public int Update(object poco, IEnumerable<string> columns)
public int Update(object poco)
public int Update(object poco, object primaryKeyValue)
public int Update(object poco, object primaryKeyValue, IEnumerable<string> columns)
public int Update<T>(string sql, params object[] args)
public int Update<T>(Sql sql)
private int ExecuteUpdate(string tableName, string primaryKeyName, object poco, object primaryKeyValue, IEnumerable<string> columns)
#endregion #region operation: Delete
public int Delete(string tableName, string primaryKeyName, object poco)
public int Delete(string tableName, string primaryKeyName, object poco, object primaryKeyValue)
public int Delete(object poco)
public int Delete<T>(object pocoOrPrimaryKey)
public int Delete<T>(string sql, params object[] args)
public int Delete<T>(Sql sql)
#endregion #region operation: IsNew
public bool IsNew(string primaryKeyName, object poco)
protected virtual bool IsNew(string primaryKeyName, PocoData pd, object poco)
public bool IsNew(object poco)
#endregion #region operation: Save
public void Save(string tableName, string primaryKeyName, object poco)
public void Save(object poco)
#endregion
#region operation: Multi-Poco Query/Fetch
public List<TRet> Fetch<T1, T2, TRet>(Func<T1, T2, TRet> cb, string sql, params object[] args)
public List<TRet> Fetch<T1, T2, T3, TRet>(Func<T1, T2, T3, TRet> cb, string sql, params object[] args)
public List<TRet> Fetch<T1, T2, T3, T4, TRet>(Func<T1, T2, T3, T4, TRet> cb, string sql, params object[] args)
public IEnumerable<TRet> Query<T1, T2, TRet>(Func<T1, T2, TRet> cb, string sql, params object[] args)
public IEnumerable<TRet> Query<T1, T2, T3, TRet>(Func<T1, T2, T3, TRet> cb, string sql, params object[] args)
public IEnumerable<TRet> Query<T1, T2, T3, T4, TRet>(Func<T1, T2, T3, T4, TRet> cb, string sql, params object[] args)
public List<TRet> Fetch<T1, T2, TRet>(Func<T1, T2, TRet> cb, Sql sql)
public List<TRet> Fetch<T1, T2, T3, TRet>(Func<T1, T2, T3, TRet> cb, Sql sql)
public List<TRet> Fetch<T1, T2, T3, T4, TRet>(Func<T1, T2, T3, T4, TRet> cb, Sql sql)
public IEnumerable<TRet> Query<T1, T2, TRet>(Func<T1, T2, TRet> cb, Sql sql)
public IEnumerable<TRet> Query<T1, T2, T3, TRet>(Func<T1, T2, T3, TRet> cb, Sql sql)
public IEnumerable<TRet> Query<T1, T2, T3, T4, TRet>(Func<T1, T2, T3, T4, TRet> cb, Sql sql)
public List<T1> Fetch<T1, T2>(string sql, params object[] args)
public List<T1> Fetch<T1, T2, T3>(string sql, params object[] args)
public List<T1> Fetch<T1, T2, T3, T4>(string sql, params object[] args)
public IEnumerable<T1> Query<T1, T2>(string sql, params object[] args)
public IEnumerable<T1> Query<T1, T2, T3>(string sql, params object[] args)
public IEnumerable<T1> Query<T1, T2, T3, T4>(string sql, params object[] args)
public List<T1> Fetch<T1, T2>(Sql sql)
public List<T1> Fetch<T1, T2, T3>(Sql sql)
public List<T1> Fetch<T1, T2, T3, T4>(Sql sql)
public IEnumerable<T1> Query<T1, T2>(Sql sql)
public IEnumerable<T1> Query<T1, T2, T3>(Sql sql)
public IEnumerable<T1> Query<T1, T2, T3, T4>(Sql sql)
public IEnumerable<TRet> Query<TRet>(Type[] types, object cb, string sql, params object[] args)
#endregion #region Last Command
public string LastSQL
public object[] LastArgs
public string LastCommand
#endregion #region FormatCommand
public string FormatCommand(IDbCommand cmd)
public string FormatCommand(string sql, object[] args)
#endregion #region Public Properties
public IMapper DefaultMapper
public bool EnableAutoSelect;
public bool EnableNamedParams;
public int CommandTimeout;
public int OneTimeCommandTimeout;
public IProvider Provider
public string ConnectionString
public IsolationLevel? IsolationLevel
#endregion #region Member Fields
// Member variables
private IMapper _defaultMapper;
private string _connectionString;
private IProvider _provider;
private IDbConnection _sharedConnection;
private IDbTransaction _transaction;
private int _sharedConnectionDepth;
private int _transactionDepth;
private bool _transactionCancelled;
private string _lastSql;
private object[] _lastArgs;
private string _paramPrefix;
private DbProviderFactory _factory;
private IsolationLevel? _isolationLevel;
#endregion #region Internal operations
internal void ExecuteNonQueryHelper(IDbCommand cmd);
internal object ExecuteScalarHelper(IDbCommand cmd);
internal void DoPreExecute(IDbCommand cmd);
#endregion
PetaPoco轻量级ORM框架 - Database API 手册的更多相关文章
- PetaPoco轻量级ORM框架 - 入门安装
PetaPoco 是一个开源轻量级ORM,够小,够快,单文件 在GitHub上有很高的人气 1377星,几年来作者一直在更新 当前版本6.0.317 - Netstandard 2.0(同时支持.ne ...
- PetaPoco轻量级ORM框架 - 对Database类的进行扩展,可以返回Table格式数据
一.有时我们需要将常用的功能添加到PetaPoco中的Database类中 实现方式有2种,以下以查询字段为例 1.通过扩展方式实现,此方式不改变被调用(Database)类名(只能增加方法) pub ...
- .NET轻量级ORM框架Dapper入门精通
一.课程介绍 本次分享课程包含两个部分<.NET轻量级ORM框架Dapper修炼手册>和<.NET轻量级ORM框架Dapper葵花宝典>,阿笨将带领大家一起领略轻量级ORM框架 ...
- 轻量级ORM框架初探-Dapper与PetaPoco的基本使用
一.EntityFramework EF是传统的ORM框架,也是一个比较重量级的ORM框架.这里仍然使用EF的原因在于为了突出轻量级ORM框架的性能,所谓有对比才有更优的选择. 1.1 准备一张数据库 ...
- C# 性能优化 之 秒表 Stopwatch。 Dapper一个和petapoco差不多的轻量级ORM框架
Sweet小马 小马同学的编程日记. C# 性能优化 之 秒表 Stopwatch. 生词解释:Diagnostics[,daɪəg'nɑstɪks] n.诊断学 using System.Diagn ...
- ASP.NET MVC 使用 Petapoco 微型ORM框架+NpgSql驱动连接 PostgreSQL数据库
前段时间在园子里看到了小蝶惊鸿 发布的有关绿色版的Linux.NET——“Jws.Mono”.由于我对.Net程序跑在Linux上非常感兴趣,自己也看了一些有关mono的资料,但是一直没有时间抽出时间 ...
- 分享自己写的基于Dapper的轻量级ORM框架~
1.说明 本项目是一个使用.NET Standard 2.0开发的,基于 Dapper 的轻量级 ORM 框架,包含基本的CRUD以及根据表达式进行一些操作的方法,目前只针对单表,不包含多表连接操作. ...
- 视频教程--ASP.NET MVC 使用 Petapoco 微型ORM框架+NpgSql驱动连接 PostgreSQL数据库
说好的给园子里的朋友们录制与<ASP.NET MVC 使用 Petapoco 微型ORM框架+NpgSql驱动连接 PostgreSQL数据库> 这篇博客相对应的视频,由于一个月一来没有时 ...
- c# 轻量级ORM框架 实现(一)
发布一个自己写的一个轻量级ORM框架,本框架设计期初基于三层架构.所以从命名上来看,了解三层的朋友会很好理解. 设计该框架的目的:不想重复的写增删改查,把精力放到功能实现上. 发布改框架的原因:希望给 ...
随机推荐
- <python数据挖掘入门与实战>代码
从百度搜索,净是csdn下载的,现在csdn下载弄的很恶心,垄断并且只想赚钱了,不想使用, 去github上找到了. https://github.com/PacktPublishing/Learni ...
- c之指针与数组(2)Dynamic Data Structures: Malloc and Free--转载
http://www.howstuffworks.com/c29.htm http://computer.howstuffworks.com/c.htm Dynamic Data Structures ...
- 关于UI回调Invoker的实现(一)
打算写一个DirectUI库,在写其中底层窗口的回调构造的时候遇到一个问题. Invoker是一个模板,因为closure的关系,它必须保存一个类对象的指针,和回调函数的地址.而函数调用的时候,就可以 ...
- c#参数修饰符-params
先来理解一下理论知识 params可以设置使用长度可变的参数. 使用要求: 1.在一个方法声明的参数中,只能有一个params修饰符,且被修饰的参数之后不能有其他参数(这一点就像“可选参数必须在必选参 ...
- java map常用的4种遍历方法
public static void main(String[] args) { Map<String, String> map = new HashMap<String, Stri ...
- [LeetCode]Swap Nodes in Pairs题解
Swap Nodes in Pairs: Given a linked list, swap every two adjacent nodes and return its head. For exa ...
- Java - 线程基本概念
[java并发编程实战]-----线程基本概念 线程状态图 说明:线程共包括以下5种状态.1. 新建状态(New) : 线程对象被创建后,就进入了新建状态.例如,Thread thre ...
- Web安全相关(四):过多发布(Over Posting)
简介 过多发布的内容相对比较简单,因此,我只打算把原文中的一些关键信息翻译一下.原文链接如下: http://www.asp.net/mvc/overview/getting-started/gett ...
- H5上滑跳转页面
方法一: jquery方法 movePage($('body')); function movePage(dom) { var startY, moveY, moveSpave; dom.on(&qu ...
- BZOJ1014: [JSOI2008]火星人prefix(splay 二分 hash)
题意 题目链接 Sol 一眼splay + 二分hash,不过区间splay怎么写来着呀 试着写了两个小时发现死活不对 看了一下yyb的代码发现自己根本就不会splay.... // luogu-ju ...