/// <summary> /// Insert 解析并执行 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="_MemberInitExpression"></param> /// <param name="LastInsertId"></param> /// <returns></returns> public object Insert <T>(MemberInitExpression _MemberInitExpression) { var _Sql_Tuple = new InsertAnalysis <T>().Create(_MemberInitExpression, LastInsertId, this); var _Sql = _Sql_Tuple.Item1; object _KeyId = null; //如果开启了 Commit 状态 if (Ado.CommitState) { _KeyId = Ado._DbConnection.ExecuteScalar(_Sql.Code.ToString(), _Sql.GetDynamicParameters(), Ado._DbTransaction); } else { _KeyId = Ado.ExecuteScalar(_Sql.Code.ToString(), _Sql.GetDynamicParameters()); } if (_KeyId == null) { return(_Sql_Tuple.Item2); } else { return(_KeyId); } }
/// <summary> /// 获取 Count /// </summary> /// <param name="Ado"></param> /// <param name="_Sql"></param> public int Count(SQL _Sql) { var _New_Sql = new CountAnalysis().Create(_Sql); Analysis.ToSql(_New_Sql, Ado.CommitState); return(Ado.ExecuteScalar <int>(_New_Sql.Code.ToString(), _Sql.GetDynamicParameters())); }
/// <summary> /// Max /// </summary> /// <param name="_LambdaExpression"></param> /// <param name="Ado"></param> /// <param name="_Sql"></param> /// <returns></returns> public T Sum <T>(LambdaExpression _LambdaExpression, SQL _Sql) { var _New_Sql = new Max_Min_Sum_Analysis().CreateSum(_LambdaExpression, _Sql); Analysis.ToSql(_New_Sql, Ado.CommitState); return(Ado.ExecuteScalar <T>(_New_Sql.Code.ToString(), _Sql.GetDynamicParameters())); }
/// <summary> /// Min /// </summary> /// <param name="_LambdaExpression"></param> /// <param name="Ado"></param> /// <param name="_Sql"></param> /// <returns></returns> public T Min <T>(LambdaExpression _LambdaExpression, SQL _Sql) { new Max_Min_Sum_Analysis(_Sql, "MIN").Visit(_LambdaExpression); Analysis.ToSql(_Sql, Ado.CommitState); return(Ado.ExecuteScalar <T>(_Sql.Code.ToString(), _Sql.GetDynamicParameters())); }