/// <summary> /// 单表操作,一次性存储多条数据 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="ctrl"></param> /// <param name="data"></param> public static ActionResult <int> SaveData <T>(this IData instance, T[] data, int[][] columns = null) { IDBHelper db = DbFactory.Execute(); db.BeginTransaction(); var i = 0; foreach (T t in data) { int[] column; try { column = columns[i]; } catch (Exception e) { return(ActionResult <int> .SetError(e.Message, -1)); } var sqlCommand = new SqlExpression().Insert <T>().Values(column, t); try { db.ExecuteNonQuery(sqlCommand.Command, CommandType.Text, sqlCommand.ToParameters()); } catch (Exception e) { return(ActionResult <int> .SetError(e.Message, -1)); } i++; } db.Commit(); return(ActionResult <int> .SetSuccess("Saved successful.")); }
public void Commit() { _iHelper.Commit(); }
/// <summary> 提交默认事务 /// </summary> public void Commit() { _DBHelper.Commit(); }