Example #1
0
 /// <summary>
 /// 添加数据
 /// </summary>
 /// <typeparam name="valueType">数据类型</typeparam>
 /// <typeparam name="modelType">模型类型</typeparam>
 /// <param name="sqlTool">SQL操作工具</param>
 /// <param name="transaction">事务操作</param>
 /// <param name="value">添加数据</param>
 /// <param name="query">添加数据查询信息</param>
 /// <returns></returns>
 internal override bool Insert <valueType, modelType>(Sql.Table <valueType, modelType> sqlTool, Transaction transaction, valueType value, ref InsertQuery query)
 {
     if (sqlTool.CallOnInsert(value) && executeNonQuery(transaction, query.InsertSql) > 0)
     {
         sqlTool.CallOnInserted(transaction, value);
         return(true);
     }
     return(false);
 }
Example #2
0
 /// <summary>
 /// 添加数据
 /// </summary>
 /// <typeparam name="valueType">数据类型</typeparam>
 /// <typeparam name="modelType">模型类型</typeparam>
 /// <param name="sqlTool">SQL操作工具</param>
 /// <param name="transaction">事务操作</param>
 /// <param name="value">添加数据</param>
 /// <param name="query">添加数据查询信息</param>
 /// <returns></returns>
 internal override ReturnType Insert <valueType, modelType>(Sql.Table <valueType, modelType> sqlTool, Transaction transaction, valueType value, ref InsertQuery query)
 {
     if (sqlTool.CallOnInsert(value))
     {
         if (executeNonQuery(transaction, query.Sql) > 0)
         {
             sqlTool.CallOnInserted(transaction, value);
             return(ReturnType.Success);
         }
         return(ReturnType.ExecuteFailed);
     }
     return(ReturnType.EventCancel);
 }
Example #3
0
 /// <summary>
 /// 添加数据
 /// </summary>
 /// <typeparam name="valueType">数据类型</typeparam>
 /// <typeparam name="modelType">模型类型</typeparam>
 /// <param name="sqlTool">SQL操作工具</param>
 /// <param name="transaction">事务操作</param>
 /// <param name="array">数据数组</param>
 /// <returns></returns>
 internal override SubArray <valueType> Insert <valueType, modelType>(Sql.Table <valueType, modelType> sqlTool, Transaction transaction, ref SubArray <valueType> array)
 {
     if (sqlTool.CallOnInsert(ref array))
     {
         MemberMap <modelType> memberMap = MemberMap <modelType> .Default;
         InsertQuery           query     = new InsertQuery();
         foreach (valueType value in array)
         {
             insert(sqlTool, value, memberMap, ref query);
             if (executeNonQuery(transaction, query.InsertSql) <= 0)
             {
                 return(default(SubArray <valueType>));
             }
         }
         sqlTool.CallOnInserted(transaction, array);
         return(array);
     }
     return(default(SubArray <valueType>));
 }
Example #4
0
 /// <summary>
 /// 添加数据
 /// </summary>
 /// <typeparam name="valueType">数据类型</typeparam>
 /// <typeparam name="modelType">模型类型</typeparam>
 /// <param name="sqlTool">SQL操作工具</param>
 /// <param name="connection">SQL连接</param>
 /// <param name="value">添加数据</param>
 /// <param name="query">添加数据查询信息</param>
 /// <param name="isIgnoreTransaction">是否忽略应用程序事务</param>
 /// <returns></returns>
 internal bool Insert <valueType, modelType>(Sql.Table <valueType, modelType> sqlTool, ref DbConnection connection, valueType value, ref InsertQuery query, bool isIgnoreTransaction)
     where valueType : class, modelType
     where modelType : class
 {
     if (sqlTool.CallOnInsert(value))
     {
         if (isIgnoreTransaction)
         {
             return(Insert(sqlTool, ref connection, value, ref query));
         }
         if (AutoCSer.DomainUnload.Unloader.TransactionStart(false))
         {
             try
             {
                 return(Insert(sqlTool, ref connection, value, ref query));
             }
             finally { AutoCSer.DomainUnload.Unloader.TransactionEnd(); }
         }
     }
     return(false);
 }
Example #5
0
 /// <summary>
 /// 添加数据
 /// </summary>
 /// <typeparam name="valueType">数据类型</typeparam>
 /// <typeparam name="modelType">模型类型</typeparam>
 /// <param name="sqlTool">SQL操作工具</param>
 /// <param name="connection">SQL连接</param>
 /// <param name="array">数据数组</param>
 /// <param name="isIgnoreTransaction">是否忽略应用程序事务</param>
 /// <returns></returns>
 internal SubArray <valueType> Insert <valueType, modelType>(Sql.Table <valueType, modelType> sqlTool, ref DbConnection connection, ref SubArray <valueType> array, bool isIgnoreTransaction)
     where valueType : class, modelType
     where modelType : class
 {
     if (sqlTool.CallOnInsert(ref array))
     {
         if (isIgnoreTransaction)
         {
             return(Insert(sqlTool, ref connection, ref array));
         }
         if (AutoCSer.DomainUnload.Unloader.TransactionStart(false))
         {
             try
             {
                 return(Insert(sqlTool, ref connection, ref array));
             }
             finally { AutoCSer.DomainUnload.Unloader.TransactionEnd(); }
         }
     }
     return(default(SubArray <valueType>));
 }