public override string VisitExpression(Type dataType, DMSExcuteType excuteType, int ParamIndex, ref string ParamSql, ref List <ParamInfo> ParamList) { this.ExcuteType = excuteType; this._strSql = new StringBuilder(); this._ParamSql = new StringBuilder(); this._ParamList = new List <ParamInfo>(); this._paramIndex = ParamIndex; if (this.Expression != null) { this.Visit(this.Expression); } string resultSql = _strSql.ToString(); if (resultSql.Length > 0 && resultSql.StartsWith(",")) { resultSql = resultSql.TrimStart(','); } ParamSql = _ParamSql.ToString(); if (ParamSql.Length > 0 && ParamSql.StartsWith(",")) { ParamSql = ParamSql.TrimStart(','); } ParamList = this._ParamList; return(resultSql); }
internal static DMS <T> DMSInsert <T>(this DMS <T> dms, DMSExcuteType excutetype, System.Linq.Expressions.Expression <Func <T, T> > columns) where T : class #endif { dms.ExcuteType = excutetype; dms.ColumnsExpressioin.Expression = null; dms.ColumnsExpressioin.Append <T, T>(columns); return(dms); }
public override string VisitExpression(Type dataType, DMSExcuteType excuteType, int ParamIndex, ref string ParamSql, ref List <ParamInfo> ParamList) { this.ExcuteType = excuteType; this._strSql = new StringBuilder(); this._ParamSql = new StringBuilder(); ParamList = new List <ParamInfo>(); if (this.TableKeys == null) { this.TableKeys = new List <DMSTableKeys>(); } if (this.Expression != null) { this.Visit(this.Expression); } ParamList = new List <ParamInfo>(); if (this.ExcuteType == DMSExcuteType.UPDATE_WHERE) { string resultSql = _strSql.ToString(); if (resultSql.Length > 0 && resultSql.EndsWith(",")) { resultSql = resultSql.TrimEnd(','); } ParamSql = resultSql; string tableSql = this.TableKeys.FirstOrDefault().TableSpecialName; if (this.SplitExpression.TableMapping.TokenFlag == true) { tableSql = this.Provider.BuildColumnName(tableSql); } return(tableSql); } else if (this.ExcuteType == DMSExcuteType.INSERT_SELECT) { string resultSql = _strSql.ToString(); if (resultSql.Length > 0 && resultSql.EndsWith(",")) { resultSql = resultSql.TrimEnd(','); } var tableSql = resultSql.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); if (tableSql.Length == 2) { _ParamSql = new StringBuilder(tableSql[1]); _ParamSql.Append(this.Provider.As + " "); var lastTableKeys = this.TableKeys.LastOrDefault(); string text = lastTableKeys.TableSpecialName; if (this.SplitExpression.TableMapping.TokenFlag == true) { text = this.Provider.BuildColumnName(text); } _ParamSql.Append(text); ParamSql = _ParamSql.ToString(); return(tableSql[0]); } } return(this._strSql.ToString()); }
public override string VisitExpression(Type dataType, DMSExcuteType excuteType, int ParamIndex, ref string ParamSql, ref List <ParamInfo> ParamList) { this.ExcuteType = excuteType; this._strSql = new StringBuilder(); this._ParamSql = new StringBuilder(); this._paramIndex = ParamIndex; if (this.Expression != null) { this.Visit(this.Expression); } ParamList = this._ParamList; string resultSql = _strSql.ToString(); return(resultSql); }
internal static DMS <T> DMSInsert <T>(this DMS <T> dms, DMSExcuteType excutetype, T entity) where T : class #endif { dms.ExcuteType = excutetype; if (entity is IEntity) { IDictionary <string, object> ChangedProperties = ((IEntity)entity).ChangedMappingProperties; if (ChangedProperties == null || ChangedProperties.Count == 0) { Log.Debug(ReflectionUtils.GetMethodBaseInfo(System.Reflection.MethodBase.GetCurrentMethod()), "插入字段为空,不能进行添加数据", null); throw new DMSFrameException("插入字段为空,不能进行添加数据"); } dms.ColumnsExpressioin.Append <T, IDictionary <string, object> >(q => ChangedProperties); } else { dms.ColumnsExpressioin.Append <T, T>(q => entity); } return(dms); }
/// <summary> /// /// </summary> /// <typeparam name="T"></typeparam> /// <param name="ExcuteType"></param> /// <param name="countsql"></param> /// <param name="sql"></param> /// <param name="param"></param> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <param name="totalRecord"></param> /// <returns></returns> public ConditionResult <T> GetConditionResult <T>(DMSExcuteType ExcuteType, string countsql, string sql, DynamicParameters param, int pageIndex, int pageSize, int totalRecord) where T : class { ConditionResult <T> resultList = new ConditionResult <T>() { PageIndex = pageIndex, PageSize = pageSize, TotalRecord = 0, AllowPaging = true, ResultList = new List <T>(), }; using (System.Data.IDbConnection conn = this.GetOpenConnection()) { if (ExcuteType == DMSExcuteType.SELECT) { if (totalRecord == 0) { totalRecord = (int)DMSDbAccess.ExecuteScalar(conn, typeof(T).FullName, countsql, param); } resultList.TotalRecord = totalRecord; resultList.ResultList = DMSDbAccess.Query <T>(conn, typeof(T).FullName, sql, param, totalRecord, null, false, 30).ToList(); if (resultList.PageSize > 0) { resultList.TotalPage = resultList.TotalRecord / resultList.PageSize + (resultList.TotalRecord % resultList.PageSize == 0 ? 0 : 1); } } else if (ExcuteType == DMSExcuteType.DELETE || ExcuteType == DMSExcuteType.INSERT || ExcuteType == DMSExcuteType.UPDATE) { resultList.TotalRecord = DMSDbAccess.Execute(conn, typeof(T).FullName, sql, param); } conn.Close(); } return(resultList); }
/// <summary> /// /// </summary> /// <param name="dataType"></param> /// <param name="excuteType"></param> /// <param name="ParamIndex"></param> /// <param name="ParamSql"></param> /// <param name="ParamList"></param> /// <returns></returns> public override string VisitExpression(Type dataType, DMSExcuteType excuteType, int ParamIndex, ref string ParamSql, ref List <ParamInfo> ParamList) { throw new NotImplementedException(); }
public static DMS <T> DMSInsert <T>(this DMS <T> dms, DMSExcuteType excutetype, System.Linq.Expressions.Expression <Func <T, T> > columns) where T : class
public static DMS <T> DMSInsert <T>(this DMS <T> dms, DMSExcuteType excutetype, T entity) where T : class
/// <summary> /// /// </summary> /// <param name="dataType"></param> /// <param name="excuteType"></param> /// <param name="ParamIndex"></param> /// <param name="ParamSql"></param> /// <param name="ParamList"></param> /// <returns></returns> public abstract string VisitExpression(Type dataType, DMSExcuteType excuteType, int ParamIndex, ref string ParamSql, ref List <ParamInfo> ParamList);