码迷,mamicode.com
首页 > Windows程序 > 详细

ORM框架PetaPoco API

时间:2018-03-04 22:55:50      阅读:669      评论:0      收藏:0      [点我收藏+]

标签:clean   ltm   cut   end   provider   exe   time   etc   tco   

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)
#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

  

ORM框架PetaPoco API

标签:clean   ltm   cut   end   provider   exe   time   etc   tco   

原文地址:https://www.cnblogs.com/slwangzi/p/8506508.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!