Esempio n. 1
0
        private static void GetValueTypeList <T>(Type type, IDataReader dataReader, List <T> result)
        {
            var value = dataReader.GetValue(0);

            if (type == UtilConstants.GuidType)
            {
                value = Guid.Parse(value.ToString());
            }
            if (value == DBNull.Value)
            {
                result.Add(default(T));
            }
            else if (type.IsEnum)
            {
                result.Add((T)Enum.Parse(type, value.ObjToString()));
            }
            else
            {
                result.Add((T)Convert.ChangeType(value, UtilMethods.GetUnderType(type)));
            }
        }
Esempio n. 2
0
 private static void AddIdentificationList(QueryBuilder queryBuilder, CacheKey result)
 {
     result.IdentificationList = new List <string>();
     result.IdentificationList.Add(queryBuilder.GetTableNameString);
     result.IdentificationList.Add(queryBuilder.GetJoinValueString);
     result.IdentificationList.Add(queryBuilder.GetOrderByString);
     result.IdentificationList.Add(queryBuilder.GetGroupByString);
     result.IdentificationList.Add(queryBuilder.GetWhereValueString);
     result.IdentificationList.Add(queryBuilder.PartitionByValue);
     result.IdentificationList.Add(queryBuilder.Take.ObjToString());
     result.IdentificationList.Add(queryBuilder.Skip.ObjToString());
     result.IdentificationList.Add(queryBuilder.IsCount.ObjToString());
     result.IdentificationList.Add(UtilMethods.GetMD5(queryBuilder.GetSelectValue.ObjToString()));
     if (queryBuilder.Parameters.HasValue())
     {
         foreach (var item in queryBuilder.Parameters)
         {
             result.IdentificationList.Add(item.ParameterName + "_" + item.Value);
         }
     }
 }
Esempio n. 3
0
        protected virtual bool IsSamgeType(EntityColumnInfo ec, DbColumnInfo dc)
        {
            if (!string.IsNullOrEmpty(ec.DataType))
            {
                return(ec.DataType != dc.DataType);
            }
            var propertyType    = UtilMethods.GetUnderType(ec.PropertyInfo);
            var properyTypeName = string.Empty;

            if (propertyType.IsEnum())
            {
                properyTypeName = this.Context.Ado.DbBind.GetDbTypeName(ec.Length > 9 ? UtilConstants.LongType.Name : UtilConstants.IntType.Name);
            }
            else
            {
                properyTypeName = this.Context.Ado.DbBind.GetDbTypeName(propertyType.Name);
            }
            var dataType = dc.DataType;

            return(properyTypeName != dataType);
        }
Esempio n. 4
0
 protected override DbColumnInfo EntityColumnToDbColumn(EntityInfo entityInfo, string tableName, EntityColumnInfo item)
 {
     var propertyType = UtilMethods.GetUnderType(item.PropertyInfo);
     var result = new DbColumnInfo()
     {
         TableId = entityInfo.Columns.IndexOf(item),
         DbColumnName = item.DbColumnName.HasValue() ? item.DbColumnName : item.PropertyName,
         IsPrimarykey = item.IsPrimarykey,
         IsIdentity = item.IsIdentity,
         TableName = tableName,
         IsNullable = item.IsNullable,
         DefaultValue = item.DefaultValue,
         ColumnDescription = item.ColumnDescription,
         Length = item.Length
     };
     GetDbType(item, propertyType, result);
     if (result.DataType.Equals("varchar", StringComparison.CurrentCultureIgnoreCase) && result.Length == 0)
     {
         result.Length = 1;
     }
     return result;
 }
Esempio n. 5
0
 private void SetInsertItemByEntity(int i, T item, List <DbColumnInfo> insertItem)
 {
     if (item == null)
     {
         return;
     }
     foreach (var column in EntityInfo.Columns)
     {
         if (column.IsIgnore || column.IsOnlyIgnoreInsert)
         {
             continue;
         }
         var columnInfo = new DbColumnInfo()
         {
             Value        = column.PropertyInfo.GetValue(item, null),
             DbColumnName = GetDbColumnName(column.PropertyName),
             PropertyName = column.PropertyName,
             PropertyType = UtilMethods.GetUnderType(column.PropertyInfo),
             TableId      = i
         };
         if (columnInfo.PropertyType.IsEnum())
         {
             columnInfo.Value = Convert.ToInt64(columnInfo.Value);
         }
         if (column.IsJson && columnInfo.Value != null)
         {
             columnInfo.Value = this.Context.Utilities.SerializeObject(columnInfo.Value);
         }
         var tranColumn = EntityInfo.Columns.FirstOrDefault(it => it.IsTranscoding && it.DbColumnName.Equals(column.DbColumnName, StringComparison.CurrentCultureIgnoreCase));
         if (tranColumn != null && columnInfo.Value.HasValue())
         {
             columnInfo.Value = UtilMethods.EncodeBase64(columnInfo.Value.ToString());
         }
         insertItem.Add(columnInfo);
     }
 }
Esempio n. 6
0
        private void ResolveHasValue(ExpressionParameter parameter, MemberExpression expression)
        {
            parameter.CommonTempData = CommonTempDataType.Result;
            this.Expression          = expression.Expression;
            this.Start();
            var methodParamter = new MethodCallExpressionArgs()
            {
                IsMember = true, MemberName = parameter.CommonTempData, MemberValue = null
            };

            if (expression.Expression?.Type != null)
            {
                methodParamter.Type = UtilMethods.GetUnderType(expression.Expression?.Type);
            }
            var result = this.Context.DbMehtods.HasValue(new MethodCallExpressionModel()
            {
                Args = new List <MethodCallExpressionArgs>()
                {
                    methodParamter
                }
            });

            if (parameter.BaseExpression != null && ExpressionTool.IsLogicOperator(parameter.BaseExpression) && parameter.IsLeft == true)
            {
                if (base.Context.Result.Contains(ExpressionConst.FormatSymbol))
                {
                    base.Context.Result.Replace(ExpressionConst.FormatSymbol, "");
                }
                this.Context.Result.Append(result + " " + ExpressionTool.GetOperator(parameter.BaseExpression.NodeType) + " ");
            }
            else
            {
                this.Context.Result.Append(result);
            }
            parameter.CommonTempData = null;
        }
Esempio n. 7
0
        private void BindMethod(ILGenerator generator, EntityColumnInfo columnInfo, int ordinal)
        {
            IDbBind    bind             = Context.Ado.DbBind;
            bool       isNullableType   = false;
            MethodInfo method           = null;
            Type       bindPropertyType = UtilMethods.GetUnderType(columnInfo.PropertyInfo, ref isNullableType);
            string     dbTypeName       = UtilMethods.GetParenthesesValue(DataRecord.GetDataTypeName(ordinal));

            if (dbTypeName.IsNullOrEmpty())
            {
                dbTypeName = bindPropertyType.Name;
            }
            string propertyName      = columnInfo.PropertyName;
            string validPropertyName = bind.GetPropertyTypeName(dbTypeName);

            validPropertyName = validPropertyName == "byte[]" ? "byteArray" : validPropertyName;
            CSharpDataType validPropertyType = (CSharpDataType)Enum.Parse(typeof(CSharpDataType), validPropertyName);

            #region Sqlite Logic
            if (this.Context.CurrentConnectionConfig.DbType == DbType.Sqlite)
            {
                if (bindPropertyType.IsEnum())
                {
                    method = isNullableType ? getConvertEnum_Null.MakeGenericMethod(bindPropertyType) : getEnum.MakeGenericMethod(bindPropertyType);
                }
                else if (bindPropertyType == UtilConstants.IntType)
                {
                    method = isNullableType ? getConvertInt32 : getInt32;
                }
                else if (bindPropertyType == UtilConstants.ByteType)
                {
                    method = isNullableType ? getConvertByte : getByte;
                }
                else if (bindPropertyType == UtilConstants.StringType)
                {
                    method = getString;
                }
                else
                {
                    method = getConvertValueMethod.MakeGenericMethod(columnInfo.PropertyInfo.PropertyType);
                }
                generator.Emit(OpCodes.Call, method);
                return;
            }
            ;
            #endregion

            #region Common Database Logic
            string bindProperyTypeName = bindPropertyType.Name.ToLower();
            bool   isEnum = bindPropertyType.IsEnum();
            if (isEnum)
            {
                validPropertyType = CSharpDataType.@enum;
            }
            switch (validPropertyType)
            {
            case CSharpDataType.@int:
                CheckType(bind.IntThrow, bindProperyTypeName, validPropertyName, propertyName);
                if (bindProperyTypeName.IsContainsIn("int", "int32"))
                {
                    method = isNullableType ? getConvertInt32 : getInt32;
                }
                if (bindProperyTypeName.IsContainsIn("int64"))
                {
                    method = isNullableType ? getConvertInt64 : getInt64;
                }
                if (bindProperyTypeName.IsContainsIn("byte"))
                {
                    method = isNullableType ? getConvertByte : getByte;
                }
                if (bindProperyTypeName.IsContainsIn("int16"))
                {
                    method = isNullableType ? getConvertInt16 : getInt16;
                }
                break;

            case CSharpDataType.@bool:
                if (bindProperyTypeName == "bool" || bindProperyTypeName == "boolean")
                {
                    method = isNullableType ? getConvertBoolean : getBoolean;
                }
                break;

            case CSharpDataType.@string:
                CheckType(bind.StringThrow, bindProperyTypeName, validPropertyName, propertyName);
                method = getString;
                if (bindProperyTypeName == "guid")
                {
                    method = isNullableType ? getConvertStringGuid : getStringGuid;
                }
                break;

            case CSharpDataType.DateTime:
                CheckType(bind.DateThrow, bindProperyTypeName, validPropertyName, propertyName);
                if (bindProperyTypeName == "datetime")
                {
                    method = isNullableType ? getConvertDateTime : getDateTime;
                }
                if (bindProperyTypeName == "datetime" && dbTypeName.ToLower() == "time")
                {
                    method = isNullableType ? getConvertTime : getTime;
                }
                break;

            case CSharpDataType.@decimal:
                CheckType(bind.DecimalThrow, bindProperyTypeName, validPropertyName, propertyName);
                if (bindProperyTypeName == "decimal")
                {
                    method = isNullableType ? getConvertDecimal : getDecimal;
                }
                break;

            case CSharpDataType.@float:
            case CSharpDataType.@double:
                CheckType(bind.DoubleThrow, bindProperyTypeName, validPropertyName, propertyName);
                if (bindProperyTypeName.IsIn("double", "single") && dbTypeName != "real")
                {
                    method = isNullableType ? getConvertDouble : getDouble;
                }
                else
                {
                    method = isNullableType ? getConvertFloat : getFloat;
                }
                if (dbTypeName.Equals("float", StringComparison.CurrentCultureIgnoreCase) && isNullableType && bindProperyTypeName.Equals("single", StringComparison.CurrentCultureIgnoreCase))
                {
                    method = getConvertDoubleToFloat;
                }
                if (bindPropertyType == UtilConstants.DecType)
                {
                    method = getConvertValueMethod.MakeGenericMethod(bindPropertyType);
                }
                if (bindPropertyType == UtilConstants.IntType)
                {
                    method = getConvertValueMethod.MakeGenericMethod(bindPropertyType);
                }
                break;

            case CSharpDataType.Guid:
                CheckType(bind.GuidThrow, bindProperyTypeName, validPropertyName, propertyName);
                if (bindProperyTypeName == "guid")
                {
                    method = isNullableType ? getConvertGuid : getGuid;
                }
                break;

            case CSharpDataType.@byte:
                if (bindProperyTypeName == "byte")
                {
                    method = isNullableType ? getConvertByte : getByte;
                }
                break;

            case CSharpDataType.@enum:
                method = isNullableType ? getConvertEnum_Null.MakeGenericMethod(bindPropertyType) : getEnum.MakeGenericMethod(bindPropertyType);
                break;

            case CSharpDataType.@short:
                CheckType(bind.ShortThrow, bindProperyTypeName, validPropertyName, propertyName);
                if (bindProperyTypeName == "int16" || bindProperyTypeName == "short")
                {
                    method = isNullableType ? getConvertInt16 : getInt16;
                }
                break;

            case CSharpDataType.@long:
                if (bindProperyTypeName == "int64" || bindProperyTypeName == "long")
                {
                    method = isNullableType ? getConvertInt64 : getInt64;
                }
                break;

            case CSharpDataType.DateTimeOffset:
                method = isNullableType ? getConvertdatetimeoffset : getdatetimeoffset;
                if (bindProperyTypeName == "datetime")
                {
                    method = isNullableType ? getConvertdatetimeoffsetDate : getdatetimeoffsetDate;
                }
                break;

            default:
                method = getConvertValueMethod.MakeGenericMethod(bindPropertyType);
                break;
            }
            if (method == null && bindPropertyType == UtilConstants.StringType)
            {
                method = getConvertString;
            }
            if (bindPropertyType == UtilConstants.ObjType)
            {
                method = getConvertValueMethod.MakeGenericMethod(bindPropertyType);
            }
            if (method == null)
            {
                method = isNullableType ? getOtherNull.MakeGenericMethod(bindPropertyType) : getOther.MakeGenericMethod(bindPropertyType);
            }

            generator.Emit(OpCodes.Call, method);
            #endregion
        }
Esempio n. 8
0
 public virtual void RepairReplicationParameters(ref string appendSql, SugarParameter[] parameters, int addIndex)
 {
     UtilMethods.RepairReplicationParameters(ref appendSql, parameters, addIndex);
 }
Esempio n. 9
0
 public virtual string GetPackTable(string sql, string shortName)
 {
     return(UtilMethods.GetPackTable(sql, shortName));
 }
Esempio n. 10
0
        public string GeDateFormat(string formatString, string value)
        {
            var parameter = new MethodCallExpressionArgs()
            {
                IsMember = true, MemberValue = DateType.Year
            };
            var parameter2 = new MethodCallExpressionArgs()
            {
                IsMember = true, MemberName = value
            };
            var parameters = new MethodCallExpressionModel()
            {
                Args = new List <MethodCallExpressionArgs>()
                {
                    parameter2, parameter
                }
            };
            var begin = @"^";
            var end   = @"$";

            formatString = formatString.Replace("yyyy", begin + UtilMethods.ConvertStringToNumbers(this.GetMethodValue("DateValue", parameters).ObjToString()) + end);
            formatString = formatString.Replace("yy", begin + UtilMethods.ConvertStringToNumbers(this.GetMethodValue("DateValue", parameters).ObjToString()) + end);

            parameters.Args.Last().MemberValue = DateType.Month;
            formatString = formatString.Replace("MM", begin + UtilMethods.ConvertStringToNumbers(this.GetMethodValue("DateValue", parameters).ObjToString()) + end);
            formatString = formatString.Replace("M", begin + UtilMethods.ConvertStringToNumbers(this.GetMethodValue("DateValue", parameters).ObjToString()) + end);

            parameters.Args.Last().MemberValue = DateType.Day;
            formatString = formatString.Replace("dd", begin + UtilMethods.ConvertStringToNumbers(this.GetMethodValue("DateValue", parameters).ObjToString()) + end);
            formatString = formatString.Replace("d", begin + UtilMethods.ConvertStringToNumbers(this.GetMethodValue("DateValue", parameters).ObjToString()) + end);

            parameters.Args.Last().MemberValue = DateType.Hour;
            formatString = Regex.Replace(formatString, "hh", begin + UtilMethods.ConvertStringToNumbers(this.GetMethodValue("DateValue", parameters).ObjToString()) + end, RegexOptions.IgnoreCase);
            formatString = Regex.Replace(formatString, "h", begin + UtilMethods.ConvertStringToNumbers(this.GetMethodValue("DateValue", parameters).ObjToString()) + end, RegexOptions.IgnoreCase);

            parameters.Args.Last().MemberValue = DateType.Minute;
            formatString = formatString.Replace("mm", begin + UtilMethods.ConvertStringToNumbers(this.GetMethodValue("DateValue", parameters).ObjToString()) + end);
            formatString = formatString.Replace("m", begin + UtilMethods.ConvertStringToNumbers(this.GetMethodValue("DateValue", parameters).ObjToString()) + end);

            parameters.Args.Last().MemberValue = DateType.Second;
            formatString = formatString.Replace("ss", begin + UtilMethods.ConvertStringToNumbers(this.GetMethodValue("DateValue", parameters).ObjToString()) + end);
            formatString = formatString.Replace("s", begin + UtilMethods.ConvertStringToNumbers(this.GetMethodValue("DateValue", parameters).ObjToString()) + end);

            parameters.Args.Last().MemberValue = DateType.Millisecond;
            formatString = formatString.Replace("ms", begin + UtilMethods.ConvertStringToNumbers(this.GetMethodValue("DateValue", parameters).ObjToString()) + end);
            var items = Regex.Matches(formatString, @"\^\d+\$").Cast <Match>().ToList();

            foreach (var item in items)
            {
                formatString = formatString.Replace(item.Value, "$@" + UtilMethods.ConvertNumbersToString(item.Value.TrimStart('^').TrimEnd('$')) + "$");
            }
            var strings             = formatString.TrimStart('$').TrimEnd('$').Split('$');
            var joinStringParameter = new MethodCallExpressionModel()
            {
                Args = new List <MethodCallExpressionArgs>()
            };

            foreach (var r in strings)
            {
                if (r.Substring(0, 1) == "@")
                {
                    joinStringParameter.Args.Add(new MethodCallExpressionArgs()
                    {
                        MemberName = r.TrimStart('@')
                    });
                }
                else
                {
                    var name = base.AppendParameter(r);
                    joinStringParameter.Args.Add(new MethodCallExpressionArgs()
                    {
                        MemberName = name
                    });
                }
            }
            return(this.GetMethodValue("MergeString", joinStringParameter).ObjToString());
        }
Esempio n. 11
0
        public virtual string ToSqlString()
        {
            if (IsNoUpdateNull)
            {
                DbColumnInfoList = DbColumnInfoList.Where(it => it.Value != null).ToList();
            }
            if (IsNoUpdateDefaultValue)
            {
                DbColumnInfoList = DbColumnInfoList.Where(it => it.Value.ObjToString() != UtilMethods.DefaultForType(it.PropertyType).ObjToString()).ToList();
            }
            var groupList = DbColumnInfoList.GroupBy(it => it.TableId).ToList();
            var isSingle  = groupList.Count() == 1;

            if (isSingle)
            {
                return(ToSingleSqlString(groupList));
            }
            else
            {
                return(TomultipleSqlString(groupList));
            }
        }
Esempio n. 12
0
        public virtual void ExistLogic(EntityInfo entityInfo)
        {
            if (entityInfo.Columns.HasValue())
            {
                //Check.Exception(entityInfo.Columns.Where(it => it.IsPrimarykey).Count() > 1, "Multiple primary keys do not support modifications");

                var tableName = GetTableName(entityInfo);
                var dbColumns = this.Context.DbMaintenance.GetColumnInfosByTableName(tableName);
                ConvertColumns(dbColumns);
                var entityColumns = entityInfo.Columns.Where(it => it.IsIgnore == false).ToList();
                var dropColumns   = dbColumns
                                    .Where(dc => !entityColumns.Any(ec => dc.DbColumnName.Equals(ec.OldDbColumnName, StringComparison.CurrentCultureIgnoreCase)))
                                    .Where(dc => !entityColumns.Any(ec => dc.DbColumnName.Equals(ec.DbColumnName, StringComparison.CurrentCultureIgnoreCase)))
                                    .ToList();
                var addColumns = entityColumns
                                 .Where(ec => ec.OldDbColumnName.IsNullOrEmpty() || !dbColumns.Any(dc => dc.DbColumnName.Equals(ec.OldDbColumnName, StringComparison.CurrentCultureIgnoreCase)))
                                 .Where(ec => !dbColumns.Any(dc => ec.DbColumnName.Equals(dc.DbColumnName, StringComparison.CurrentCultureIgnoreCase))).ToList();
                var alterColumns = entityColumns
                                   .Where(ec => !dbColumns.Any(dc => dc.DbColumnName.Equals(ec.OldDbColumnName, StringComparison.CurrentCultureIgnoreCase)))
                                   .Where(ec =>
                                          dbColumns.Any(dc => dc.DbColumnName.Equals(ec.DbColumnName) &&
                                                        ((ec.Length != dc.Length && !UtilMethods.GetUnderType(ec.PropertyInfo).IsEnum() && UtilMethods.GetUnderType(ec.PropertyInfo).IsIn(UtilConstants.StringType)) ||
                                                         ec.IsNullable != dc.IsNullable ||
                                                         IsSamgeType(ec, dc)))).ToList();
                var renameColumns = entityColumns
                                    .Where(it => !string.IsNullOrEmpty(it.OldDbColumnName))
                                    .Where(entityColumn => dbColumns.Any(dbColumn => entityColumn.OldDbColumnName.Equals(dbColumn.DbColumnName, StringComparison.CurrentCultureIgnoreCase)))
                                    .ToList();


                var isMultiplePrimaryKey = dbColumns.Where(it => it.IsPrimarykey).Count() > 1 || entityColumns.Where(it => it.IsPrimarykey).Count() > 1;


                var isChange = false;
                foreach (var item in addColumns)
                {
                    this.Context.DbMaintenance.AddColumn(tableName, EntityColumnToDbColumn(entityInfo, tableName, item));
                    isChange = true;
                }
                foreach (var item in dropColumns)
                {
                    this.Context.DbMaintenance.DropColumn(tableName, item.DbColumnName);
                    isChange = true;
                }
                foreach (var item in alterColumns)
                {
                    this.Context.DbMaintenance.UpdateColumn(tableName, EntityColumnToDbColumn(entityInfo, tableName, item));
                    isChange = true;
                }
                foreach (var item in renameColumns)
                {
                    this.Context.DbMaintenance.RenameColumn(tableName, item.OldDbColumnName, item.DbColumnName);
                    isChange = true;
                }

                foreach (var item in entityColumns)
                {
                    var dbColumn = dbColumns.FirstOrDefault(dc => dc.DbColumnName.Equals(item.DbColumnName, StringComparison.CurrentCultureIgnoreCase));
                    if (dbColumn == null)
                    {
                        continue;
                    }
                    bool pkDiff, idEntityDiff;
                    KeyAction(item, dbColumn, out pkDiff, out idEntityDiff);
                    if (dbColumn != null && pkDiff && !idEntityDiff && isMultiplePrimaryKey == false)
                    {
                        var isAdd = item.IsPrimarykey;
                        if (isAdd)
                        {
                            this.Context.DbMaintenance.AddPrimaryKey(tableName, item.DbColumnName);
                        }
                        else
                        {
                            this.Context.DbMaintenance.DropConstraint(tableName, string.Format("PK_{0}_{1}", tableName, item.DbColumnName));
                        }
                    }
                    else if ((pkDiff || idEntityDiff) && isMultiplePrimaryKey == false)
                    {
                        ChangeKey(entityInfo, tableName, item);
                    }
                }
                if (isMultiplePrimaryKey)
                {
                    var oldPkNames = dbColumns.Where(it => it.IsPrimarykey).Select(it => it.DbColumnName.ToLower()).OrderBy(it => it).ToList();
                    var newPkNames = entityColumns.Where(it => it.IsPrimarykey).Select(it => it.DbColumnName.ToLower()).OrderBy(it => it).ToList();
                    if (!Enumerable.SequenceEqual(oldPkNames, newPkNames))
                    {
                        Check.Exception(true, ErrorMessage.GetThrowMessage("Modification of multiple primary key tables is not supported. Delete tables while creating", "不支持修改多主键表,请删除表在创建"));
                    }
                }
                if (isChange && IsBackupTable)
                {
                    this.Context.DbMaintenance.BackupTable(tableName, tableName + DateTime.Now.ToString("yyyyMMddHHmmss"), MaxBackupDataRows);
                }
            }
        }
Esempio n. 13
0
        private void Update(MemberInitExpression expression, ExpressionParameter parameter)
        {
            int i = 0;

            foreach (MemberBinding binding in expression.Bindings)
            {
                ++i;
                if (binding.BindingType != MemberBindingType.Assignment)
                {
                    throw new NotSupportedException();
                }
                MemberAssignment memberAssignment = (MemberAssignment)binding;
                var type       = expression.Type;
                var memberName = this.Context.GetDbColumnName(type.Name, memberAssignment.Member.Name);
                var item       = memberAssignment.Expression;
                if ((item is MemberExpression) && ((MemberExpression)item).Expression == null)
                {
                    var    paramterValue = ExpressionTool.DynamicInvoke(item);
                    string parameterName = AppendParameter(paramterValue);
                    this.Context.Result.Append(base.Context.GetEqString(memberName, parameterName));
                }
                else if (IsNotMember(item))
                {
                    if (base.Context.Result.IsLockCurrentParameter == false)
                    {
                        base.Context.Result.CurrentParameter       = parameter;
                        base.Context.Result.IsLockCurrentParameter = true;
                        parameter.IsAppendTempDate();
                        base.Expression = item;
                        base.Expression = (item as UnaryExpression).Operand;
                        base.Start();
                        parameter.IsAppendResult();
                        var result = this.Context.DbMehtods.IIF(new MethodCallExpressionModel()
                        {
                            Args = new List <MethodCallExpressionArgs>()
                            {
                                new MethodCallExpressionArgs()
                                {
                                    IsMember = true, MemberName = parameter.CommonTempData.ObjToString() + "=1"
                                },
                                new MethodCallExpressionArgs()
                                {
                                    IsMember = true, MemberName = AppendParameter(0)
                                },
                                new MethodCallExpressionArgs()
                                {
                                    IsMember = true, MemberName = AppendParameter(1)
                                }
                            }
                        });
                        parameter.Context.Result.Append(base.Context.GetEqString(memberName, result));
                        base.Context.Result.CurrentParameter = null;
                    }
                }
                else if (IsNotParameter(item))
                {
                    try
                    {
                        parameter.Context.Result.Append(base.Context.GetEqString(memberName, AppendParameter(ExpressionTool.DynamicInvoke(item).ObjToBool())));
                    }
                    catch
                    {
                        throw new NotSupportedException(item.ToString());
                    }
                }
                else if (IsMethod(item))
                {
                    if (item is UnaryExpression)
                    {
                        item = (item as UnaryExpression).Operand;
                    }
                    var callMethod = item as MethodCallExpression;
                    if (MethodTimeMapping.Any(it => it.Key == callMethod.Method.Name) || MethodMapping.Any(it => it.Key == callMethod.Method.Name) || IsExtMethod(callMethod.Method.Name) || IsSubMethod(callMethod) || callMethod.Method.DeclaringType.FullName.StartsWith(UtilConstants.AssemblyName + UtilConstants.Dot))
                    {
                        MethodCall(parameter, memberName, item);
                    }
                    else
                    {
                        var    paramterValue = ExpressionTool.DynamicInvoke(item);
                        string parameterName = AppendParameter(paramterValue);
                        this.Context.Result.Append(base.Context.GetEqString(memberName, parameterName));
                    }
                }
                else if (IsConst(item) && IsConvert(item) && UtilMethods.IsNullable(item.Type) && UtilMethods.GetUnderType(item.Type) == UtilConstants.BoolType)
                {
                    item = (item as UnaryExpression).Operand;
                    parameter.Context.Result.Append(base.Context.GetEqString(memberName, GetNewExpressionValue(item)));
                }
                else if (IsConst(item))
                {
                    base.Expression = item;
                    base.Start();
                    string parameterName = this.Context.SqlParameterKeyWord + ExpressionConst.Const + this.Context.ParameterIndex;
                    parameter.Context.Result.Append(base.Context.GetEqString(memberName, parameterName));
                    this.Context.Parameters.Add(new SugarParameter(parameterName, parameter.CommonTempData));
                    this.Context.ParameterIndex++;
                }
                else if (item is MemberExpression)
                {
                    if (base.Context.Result.IsLockCurrentParameter == false)
                    {
                        base.Context.Result.CurrentParameter       = parameter;
                        base.Context.Result.IsLockCurrentParameter = true;
                        parameter.IsAppendTempDate();
                        base.Expression = item;
                        base.Start();
                        parameter.IsAppendResult();
                        parameter.Context.Result.Append(base.Context.GetEqString(memberName, parameter.CommonTempData.ObjToString()));
                        base.Context.Result.CurrentParameter = null;
                    }
                }
                else if (item is BinaryExpression)
                {
                    var result = GetNewExpressionValue(item);
                    this.Context.Result.Append(base.Context.GetEqString(memberName, result));
                }
                else if (item is MemberInitExpression)
                {
                    try
                    {
                        var value         = ExpressionTool.DynamicInvoke(item);
                        var parameterName = AppendParameter(value);
                        parameter.Context.Result.Append(base.Context.GetEqString(memberName, parameterName));
                    }
                    catch (Exception ex)
                    {
                        throw new NotSupportedException("Not Supported " + item.ToString() + " " + ex.Message);
                    }
                }
                else if (item is NewExpression)
                {
                    try
                    {
                        var value         = ExpressionTool.DynamicInvoke(item);
                        var parameterName = AppendParameter(value);
                        parameter.Context.Result.Append(base.Context.GetEqString(memberName, parameterName));
                    }
                    catch (Exception ex)
                    {
                        throw new NotSupportedException("Not Supported " + item.ToString() + " " + ex.Message);
                    }
                }
            }
        }