Esempio n. 1
0
 public static string ReplaceSqlParameter(string itemSql, DbLiteParameter itemParameter, string newName)
 {
     itemSql = Regex.Replace(itemSql, string.Format(@"{0} ", "\\" + itemParameter.ParameterName), newName + " ", RegexOptions.IgnoreCase);
     itemSql = Regex.Replace(itemSql, string.Format(@"{0}\)", "\\" + itemParameter.ParameterName), newName + ")", RegexOptions.IgnoreCase);
     itemSql = Regex.Replace(itemSql, string.Format(@"{0}\,", "\\" + itemParameter.ParameterName), newName + ",", RegexOptions.IgnoreCase);
     itemSql = Regex.Replace(itemSql, string.Format(@"{0}$", "\\" + itemParameter.ParameterName), newName, RegexOptions.IgnoreCase);
     return(itemSql);
 }
Esempio n. 2
0
        protected virtual void PreToSql()
        {
            #region Identities
            if (!IsOffIdentity)
            {
                List <string> identities = GetIdentityKeys();
                if (identities != null && identities.Any())
                {
                    this.InsertBuilder.DbColumnInfoList = this.InsertBuilder.DbColumnInfoList.Where(it =>
                    {
                        return(!identities.Any(i => it.DbColumnName.Equals(i, StringComparison.CurrentCultureIgnoreCase)));
                    }).ToList();
                }
            }
            #endregion

            #region IgnoreColumns
            if (this.Context.IgnoreColumns != null && this.Context.IgnoreColumns.Any())
            {
                var currentIgnoreColumns = this.Context.IgnoreColumns.Where(it => it.EntityName == this.EntityInfo.EntityName).ToList();
                this.InsertBuilder.DbColumnInfoList = this.InsertBuilder.DbColumnInfoList.Where(it =>
                {
                    return(!currentIgnoreColumns.Any(i => it.PropertyName.Equals(i.PropertyName, StringComparison.CurrentCulture)));
                }).ToList();
            }

            if (this.Context.IgnoreInsertColumns != null && this.Context.IgnoreInsertColumns.Any())
            {
                var currentIgnoreColumns = this.Context.IgnoreInsertColumns.Where(it => it.EntityName == this.EntityInfo.EntityName).ToList();
                this.InsertBuilder.DbColumnInfoList = this.InsertBuilder.DbColumnInfoList.Where(it =>
                {
                    return(!currentIgnoreColumns.Any(i => it.PropertyName.Equals(i.PropertyName, StringComparison.CurrentCulture)));
                }).ToList();
            }
            #endregion
            if (this.IsSingle)
            {
                foreach (var item in this.InsertBuilder.DbColumnInfoList)
                {
                    if (this.InsertBuilder.Parameters == null)
                    {
                        this.InsertBuilder.Parameters = new List <DbLiteParameter>();
                    }
                    var paramters = new DbLiteParameter(this.SqlBuilder.SqlParameterKeyWord + item.DbColumnName, item.Value, item.PropertyType);
                    if (InsertBuilder.IsNoInsertNull && paramters.Value == null)
                    {
                        continue;
                    }
                    this.InsertBuilder.Parameters.Add(paramters);
                }
            }
        }
Esempio n. 3
0
        protected void ProperyToParameter(object parameters, PropertyInfo[] propertyInfo, string sqlParameterKeyWord, List <DbLiteParameter> listParams, Type entityType)
        {
            PropertyInfo[] properties = null;
            if (propertyInfo != null)
            {
                properties = propertyInfo;
            }
            else
            {
                properties = entityType.GetProperties();
            }

            foreach (PropertyInfo properyty in properties)
            {
                var value = properyty.GetValue(parameters, null);
                if (properyty.PropertyType.IsEnum())
                {
                    value = Convert.ToInt64(value);
                }
                if (value == null || value.Equals(DateTime.MinValue))
                {
                    value = DBNull.Value;
                }
                if (properyty.Name.ToLower().Contains("hierarchyid"))
                {
                    var parameter = new DbLiteParameter(sqlParameterKeyWord + properyty.Name, SqlDbType.Udt);
                    parameter.UdtTypeName = "HIERARCHYID";
                    parameter.Value       = value;
                    listParams.Add(parameter);
                }
                else
                {
                    var parameter = new DbLiteParameter(sqlParameterKeyWord + properyty.Name, value);
                    listParams.Add(parameter);
                }
            }
        }
Esempio n. 4
0
 public void AddQueue(string sql, DbLiteParameter parsmeter)
 {
     this.Context.AddQueue(sql, parsmeter);
 }
Esempio n. 5
0
 public IDeleteable <T> Where(string whereString, DbLiteParameter parameter)
 {
     DeleteBuilder.Parameters.Add(parameter);
     return(this);
 }