示例#1
0
文件: Page.cs 项目: yunqian44/FoxOne
        private void GetChildren(IControl e, IList <IControl> controls)
        {
            var children = controls.Where(o => o.ParentId.Equals(e.Id));

            if (children.IsNullOrEmpty())
            {
                return;
            }
            var fastType = FastType.Get(e.GetType());

            foreach (var ee in children)
            {
                var gettter = fastType.GetGetter(ee.TargetId);
                if (gettter.Type.IsGenericType)
                {
                    var instance = gettter.GetValue(e);
                    if (instance == null)
                    {
                        var t    = typeof(List <>);
                        var type = gettter.Type.GetGenericArguments()[0];
                        t        = t.MakeGenericType(type);
                        instance = Activator.CreateInstance(t);
                        gettter.SetValue(e, instance);
                    }
                    var add = instance.GetType().GetMethod("Add");
                    add.Invoke(instance, new object[] { ee });
                }
                else
                {
                    gettter.SetValue(e, ee);
                }
                GetChildren(ee, controls);
            }
        }
示例#2
0
        public static T Read <T>(IDictionary <string, object> data, Type instanceType)
        {
            if (null != data)
            {
                FastType reflection = FastType.Get(instanceType);

                object instance = Activator.CreateInstance(instanceType);

                foreach (String key in data.Keys)
                {
                    FastProperty prop =
                        reflection.Setters.SingleOrDefault(p => MatchColumnName(p.Name, key));

                    if (null != prop)
                    {
                        prop.SetValue(instance, data[key].ConvertToType(prop.Type));
                    }
                }
                return((T)instance);
            }
            else
            {
                return(default(T));
            }
        }
示例#3
0
        public static object ToEntity(this IDictionary <string, object> source, Type type)
        {
            if (source.IsNullOrEmpty())
            {
                return(null);
            }
            FastType fastType = FastType.Get(type);
            var      instance = Activator.CreateInstance(type);

            foreach (var p in fastType.Setters)
            {
                if (p.Name.IsNullOrEmpty())
                {
                    continue;
                }
                if (source.Keys.Contains(p.Name))
                {
                    p.SetValue(instance, source[p.Name].ConvertToType(p.Type));
                }
            }
            var temp = instance as IExtProperty;

            if (temp != null)
            {
                var keys = source.Keys.Where(o => o.StartsWith(SysConfig.ExtFieldName, StringComparison.OrdinalIgnoreCase));
                if (!keys.IsNullOrEmpty())
                {
                    foreach (var key in keys)
                    {
                        temp.Properties[key] = source[key];
                    }
                }
            }
            return(instance);
        }
示例#4
0
        public override object Deserialize(IDictionary <string, object> dictionary, Type type, JavaScriptSerializer serializer)
        {
            var      instance = Activator.CreateInstance(type);
            FastType ft       = FastType.Get(type);

            foreach (var p in ft.Setters)
            {
                if (!dictionary.Keys.Contains(p.Name))
                {
                    continue;
                }
                if (p.Info.GetCustomAttribute <ScriptIgnoreAttribute>(true) != null ||
                    p.Type.IsGenericType ||
                    typeof(IControl).IsAssignableFrom(p.Type))
                {
                    continue;
                }
                if (p.Info.GetCustomAttribute <HtmlEncodeAttribute>(true) != null)
                {
                    p.SetValue(instance, HttpUtility.HtmlDecode(dictionary[p.Name].ToString()));
                }
                else
                {
                    p.SetValue(instance, dictionary[p.Name]);
                }
            }
            return(instance);
        }
示例#5
0
文件: Dao.cs 项目: loloopop/FoxOne
        public int UpdateFieldsNotNull(object entity)
        {
            IList <string> includedProperties = new List <string>();

            FastProperty[] properties = FastType.Get(entity.GetType()).Setters;
            foreach (FastProperty property in properties)
            {
                if (null != property.GetValue(entity))
                {
                    includedProperties.Add(property.Name);
                }
            }
            return(this.UpdateFields(entity, includedProperties.ToArray()));
        }
示例#6
0
        public static Table ReadTable(Type type)
        {
            var table = new Table();

            table.Name   = GetTableName(type);
            table.Schema = GetSchemaName(type);
            FastType fastType = FastType.Get(type);

            foreach (var p in fastType.Setters)
            {
                if (p.Info.PropertyType.IsValueType || p.Type == typeof(string))
                {
                    var column = new Column();
                    column.Name            = p.Name;
                    column.IsNullable      = true;
                    column.IsAutoIncrement = false;
                    GetDefaultDataType(p.Type, column);
                    var attr = p.Info.GetCustomAttribute <ColumnAttribute>(true);
                    if (attr != null)
                    {
                        if (attr.IsDataField == false)
                        {
                            continue;
                        }
                        column.Name            = attr.Name.IsNullOrEmpty() ? p.Name : attr.Name;
                        column.Type            = attr.DataType.IsNullOrEmpty() ? column.Type : attr.DataType;
                        column.Length          = attr.Length.IsNullOrEmpty() ? column.Length : attr.Length;
                        column.Showable        = attr.Showable;
                        column.Editable        = attr.Editable;
                        column.Searchable      = attr.Searchable;
                        column.IsAutoIncrement = attr.IsAutoIncrement;
                    }
                    var attr1 = p.Info.GetCustomAttribute <PrimaryKeyAttribute>(true);
                    if (attr1 != null || p.Name.Equals("Id", StringComparison.OrdinalIgnoreCase))
                    {
                        column.IsKey      = true;
                        column.IsNullable = false;
                        table.Keys.Add(column);
                    }
                    column.Comment = p.Info.GetDisplayName();
                    if ("text|int|bit|datetime".Split('|').Contains(column.Type, StringComparer.OrdinalIgnoreCase))
                    {
                        column.Length = string.Empty;
                    }
                    table.Columns.Add(column);
                }
            }
            return(table);
        }
示例#7
0
        public object Resolve(string name)
        {
            object value;
            var    fastType = FastType.Get(Sec.User.GetType());
            var    getter   = fastType.GetGetter(name);

            if (getter != null)
            {
                return(getter.GetValue(Sec.User));
            }
            else
            {
                return(Sec.User.Properties.TryGetValue(name, out value) ? value : null);
            }
        }
示例#8
0
 public static void RecSave(IControl instance)
 {
     using (TransactionScope tran = new TransactionScope())
     {
         SaveComponent(instance);
         var pis = FastType.Get(instance.GetType()).Setters;
         foreach (var p in pis)
         {
             if (typeof(IControl).IsAssignableFrom(p.Type))
             {
                 var newInstance = p.GetValue(instance) as IControl;
                 if (newInstance != null)
                 {
                     newInstance.PageId   = instance.PageId;
                     newInstance.TargetId = p.Name;
                     newInstance.ParentId = instance.Id;
                     if (newInstance.Id.IsNullOrEmpty())
                     {
                         newInstance.Id = newInstance.ParentId + newInstance.GetType().Name;
                     }
                     RecSave(newInstance);
                 }
             }
             if (p.Type.IsGenericType && typeof(IEnumerable).IsAssignableFrom(p.Type) && !p.Name.Equals("Controls", StringComparison.CurrentCultureIgnoreCase))
             {
                 var lists = p.GetValue(instance) as IEnumerable;
                 if (lists != null)
                 {
                     int i = 0;
                     foreach (var list in lists)
                     {
                         var newInstance = list as IControl;
                         newInstance.PageId   = instance.PageId;
                         newInstance.TargetId = p.Name;
                         newInstance.ParentId = instance.Id;
                         if (newInstance.Id.IsNullOrEmpty())
                         {
                             newInstance.Id = newInstance.ParentId + newInstance.GetType().Name + i;
                         }
                         RecSave(newInstance);
                         i++;
                     }
                 }
             }
         }
         tran.Complete();
     }
 }
示例#9
0
        public object Resolve(string name)
        {
            object value;
            var    fastType = FastType.Get(Sec.User.GetType());
            var    getter   = fastType.GetGetter(name);

            if (name == "RoleName")
            {
                return(string.Join("|", Sec.User.Roles.Select(o => o.RoleType.Name)));
            }
            if (getter != null)
            {
                return(getter.GetValue(Sec.User));
            }
            else
            {
                return(Sec.User.Properties.TryGetValue(name, out value) ? value : null);
            }
        }
示例#10
0
        public override IDictionary <string, object> Serialize(object obj, JavaScriptSerializer serializer)
        {
            var      result       = new Dictionary <string, object>();
            FastType ft           = FastType.Get(obj.GetType());
            string   propertyName = string.Empty;

            foreach (var p in ft.Getters)
            {
                if (p.Info.GetCustomAttribute <ScriptIgnoreAttribute>(true) != null)
                {
                    continue;
                }
                propertyName = p.Info.Name;
                var attr1 = p.Info.GetCustomAttribute <ScriptNameAttribute>(true);
                if (attr1 != null)
                {
                    propertyName = attr1.Name;
                }
                if (p.Type == typeof(DateTime))
                {
                    var attr = p.Info.GetCustomAttribute <TableFieldAttribute>(true);
                    if (attr != null)
                    {
                        string value = string.Format(CultureInfo.CurrentCulture, attr.DataFormatString, new object[] { p.GetValue(obj) });
                        result.Add(propertyName, value);
                    }
                    else
                    {
                        result.Add(propertyName, p.GetValue(obj).ConvertTo <DateTime>().ToString("yyyy年MM月dd日"));
                    }
                }
                else if (p.Type.IsEnum)
                {
                    result.Add(propertyName, p.GetValue(obj).ConvertTo <int>());
                }
                else
                {
                    result.Add(propertyName, p.GetValue(obj));
                }
            }
            return(result);
        }
示例#11
0
        private void GetChildren(IControl e)
        {
            var children = Controls.Where(o => o.ParentId.Equals(e.Id));

            if (children.IsNullOrEmpty())
            {
                return;
            }
            var fastType = FastType.Get(e.GetType());

            foreach (var ee in children)
            {
                var gettter = fastType.GetGetter(ee.TargetId);
                if (gettter.Type.IsGenericType)
                {
                    var instance = gettter.GetValue(e);
                    if (instance == null)
                    {
                        var t    = typeof(List <>);
                        var type = gettter.Type.GetGenericArguments()[0];
                        t        = t.MakeGenericType(type);
                        instance = Activator.CreateInstance(t);
                        gettter.SetValue(e, instance);
                    }
                    var add = instance.GetType().GetMethod("Add");
                    add.Invoke(instance, new object[] { ee });
                }
                else
                {
                    if (gettter.GetValue(e) != null)
                    {
                        throw new FoxOneException("This Property:{0} of Control:{1} is already Set", ee.TargetId, e.Id);
                    }
                    gettter.SetValue(e, ee);
                }
                GetChildren(ee);
            }
        }
示例#12
0
        public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
        {
            var    request            = controllerContext.HttpContext.Request.Form;
            string entityTypeFullName = request[EntityFullNameHiddenName];

            if (entityTypeFullName.IsNullOrEmpty())
            {
                throw new FoxOneException("Missing_ControlType_FullName");
            }
            var    type   = TypeHelper.GetType(entityTypeFullName);
            object entity = Activator.CreateInstance(type);
            var    pis    = FastType.Get(type).Setters;

            foreach (var p in pis)
            {
                if (request.AllKeys.Contains(p.Name, StringComparer.Create(Thread.CurrentThread.CurrentCulture, true)))
                {
                    var requestValue = request[p.Name];
                    p.SetValue(entity, requestValue.ConvertToType(p.Info.PropertyType));
                }
            }
            return(entity);
        }
示例#13
0
        public override IDictionary <string, object> Serialize(object obj, JavaScriptSerializer serializer)
        {
            var      result = new Dictionary <string, object>();
            FastType ft     = FastType.Get(obj.GetType());

            foreach (var p in ft.Getters)
            {
                if (p.Info.GetCustomAttribute <ScriptIgnoreAttribute>(true) != null ||
                    p.Type.IsGenericType ||
                    typeof(IControl).IsAssignableFrom(p.Type))
                {
                    continue;
                }
                if (p.Info.GetCustomAttribute <HtmlEncodeAttribute>(true) != null)
                {
                    result.Add(p.Name, HttpUtility.HtmlEncode(p.GetValue(obj)));
                }
                else
                {
                    result.Add(p.Name, p.GetValue(obj));
                }
            }
            return(result);
        }
示例#14
0
        public static Form GetFormComponent(Type entityType)
        {
            string formId = NamingCenter.GetEntityFormId(entityType);
            string key    = NamingCenter.GetCacheKey(CacheType.ENTITY_CONFIG, formId);
            var    result = CacheHelper.GetFromCache <Form>(key, () =>
            {
                var returnValue = new Form();
                returnValue.Id  = formId;
                var pis         = FastType.Get(entityType).Setters;
                int rank        = 0;
                foreach (var fp in pis)
                {
                    var p = fp.Info;
                    if (!(p.PropertyType == typeof(string)) && !p.PropertyType.IsValueType)
                    {
                        continue;
                    }
                    object defaultValue            = null;
                    string label                   = string.Empty;
                    FormControlBase fieldComponent = null;
                    bool canModify                 = true;
                    var formAttr                   = p.GetCustomAttribute <FormFieldAttribute>(true);
                    if (formAttr != null)
                    {
                        if (!formAttr.Editable)
                        {
                            continue;
                        }
                        label        = formAttr.FormDisplayName;
                        defaultValue = formAttr.DefaultValue;
                        if (formAttr.ControlType != ControlType.None)
                        {
                            switch (formAttr.ControlType)
                            {
                            case ControlType.DateTimeRange:
                            case ControlType.DatePicker:
                                fieldComponent = new DatePicker();
                                break;

                            case ControlType.DropDownList:
                                fieldComponent = new DropDownList();
                                break;

                            case ControlType.Password:
                                fieldComponent = new TextBox()
                                {
                                    TextMode = TextMode.Password
                                };
                                break;

                            case ControlType.CheckBox:
                                fieldComponent = new CheckBox();
                                break;

                            case ControlType.CheckBoxList:
                                fieldComponent = new CheckBoxList();
                                break;

                            case ControlType.RadioButton:
                                fieldComponent = new RadioButton();
                                break;

                            case ControlType.RadioButtonList:
                                fieldComponent = new RadioButtonList();
                                break;

                            case ControlType.TextArea:
                                fieldComponent = new TextArea();
                                break;

                            case ControlType.TextEditor:
                                fieldComponent = new TextEditor();
                                break;
                            }
                        }
                        canModify = formAttr.CanModity;
                    }
                    if (fieldComponent == null)
                    {
                        if (p.PropertyType.IsEnum)
                        {
                            fieldComponent = new DropDownList()
                            {
                                DataSource = new EnumDataSource()
                                {
                                    EnumTypeFullName = p.PropertyType.FullName, EnumValueType = EnumValueType.Code
                                }
                            };
                        }
                        else if (p.PropertyType == typeof(bool))
                        {
                            fieldComponent = new DropDownList()
                            {
                                DataSource = new EnumDataSource()
                                {
                                    EnumTypeFullName = typeof(YesOrNo).FullName, EnumValueType = EnumValueType.Code
                                }
                            };
                        }
                        else if (p.PropertyType == typeof(DateTime))
                        {
                            fieldComponent = new DatePicker();
                        }
                        else
                        {
                            fieldComponent = new TextBox();
                        }
                    }
                    var formAttr1 = p.GetCustomAttribute <DataSourceAttribute>(true);
                    if (formAttr1 != null)
                    {
                        if (fieldComponent is IKeyValueDataSourceControl)
                        {
                            (fieldComponent as IKeyValueDataSourceControl).DataSource = formAttr1.GetDataSource() as IKeyValueDataSource;
                        }
                    }
                    fieldComponent.Description = p.GetDescription();
                    if (label.IsNullOrEmpty())
                    {
                        label = p.GetDisplayName();
                    }
                    var attr1 = p.GetCustomAttribute <DefaultValueAttribute>(true);
                    if (attr1 != null)
                    {
                        defaultValue = attr1.Value;
                    }
                    var attr2 = p.GetCustomAttribute <ValidatorAttribute>(true);
                    if (attr2 != null)
                    {
                        fieldComponent.Validator = attr2.ValidateString;
                    }
                    fieldComponent.Label     = label;
                    fieldComponent.Id        = p.Name;
                    fieldComponent.CanModity = canModify;
                    fieldComponent.Rank      = (++rank);
                    fieldComponent.Value     = defaultValue == null ? "" : defaultValue.ToString();
                    returnValue.Fields.Add(fieldComponent);
                }
                foreach (var btn in ControlDefaultSetting.GetDefaultFormButton())
                {
                    returnValue.Buttons.Add(btn);
                }
                returnValue.Fields.Add(new HiddenField()
                {
                    Id = ControlModelBinder.EntityFullNameHiddenName, Value = entityType.FullName + "," + entityType.Assembly.FullName
                });
                return(returnValue);
            });

            return(result.Clone() as Form);
        }
示例#15
0
        //private static readonly Dictionary<string,PropertyMapping[]> _mappingCache = new Dictionary<string,PropertyMapping[]>();
        //private static readonly ReaderWriterLockSlim _mappingLock = new ReaderWriterLockSlim();

        private static PropertyMapping[] GetSetterMappings(Type type, IDataReader reader, string mappingKey = null)
        {
            PropertyMapping[] mappings = null;

            //read from cache

            /*TODO : 暂不考虑缓存映射结果
             * if (null != mappingKey)
             * {
             *  _mappingLock.EnterReadLock();
             *  try
             *  {
             *      if (_mappingCache.TryGetValue(mappingKey, out mappings))
             *      {
             *          return mappings;
             *      }
             *  }
             *  finally
             *  {
             *      _mappingLock.ExitReadLock();
             *  }
             * }
             */

            FastType reflection         = FastType.Get(type);
            List <PropertyMapping> list = new List <PropertyMapping>();

            for (int i = 0; i < reader.FieldCount; i++)
            {
                string columnName = reader.GetName(i);

                FastProperty prop =
                    reflection.Setters.SingleOrDefault(m => MatchColumnName(m.Name, columnName));

                if (prop != null)
                {
                    list.Add(new PropertyMapping()
                    {
                        Prop = prop, Index = i
                    });
                }
            }

            mappings = list.ToArray();

            /*
             * if (null != mappingKey)
             * {
             *  _mappingLock.EnterWriteLock();
             *  try
             *  {
             *      _mappingCache[mappingKey] = mappings;
             *  }
             *  finally
             *  {
             *      _mappingLock.ExitWriteLock();
             *  }
             * }
             */

            return(mappings);
        }
示例#16
0
 internal ObjectParameters(object parameters)
 {
     this._type       = parameters.GetType();
     this._reflection = FastType.Get(_type);
     this._params     = parameters;
 }
示例#17
0
        public static Tab GetTabComponent(object instance, string parentId, string pageId)
        {
            var entityType = instance.GetType();
            var pis        = FastType.Get(entityType).Setters;
            var tab        = new Tab();

            tab.TabItems.Add(new TabItem()
            {
                Id       = "baseInfo",
                TabName  = entityType.GetDisplayName(),
                Visiable = true
            });
            var id    = (instance as IControl).Id;
            var param = new Dictionary <string, object>();

            param[NamingCenter.PARAM_PAGE_ID]   = pageId;
            param[NamingCenter.PARAM_PARENT_ID] = parentId;
            foreach (var fp in pis)
            {
                var p = fp.Info;
                param[NamingCenter.PARAM_TARGET_ID] = p.Name;
                if (p.GetCustomAttribute <FormFieldAttribute>(true) != null || p.GetCustomAttribute <BrowsableAttribute>(true) != null)
                {
                    continue;
                }
                if (p.PropertyType.IsGenericType)
                {
                    if (typeof(IDictionary <string, object>).IsAssignableFrom(p.PropertyType))
                    {
                        continue;
                    }
                    var typeArgument = p.PropertyType.GetGenericArguments()[0];
                    var newTab       = new TabItem()
                    {
                        Id       = p.Name,
                        TabName  = p.GetDisplayName(),
                        Visiable = true
                    };
                    param[NamingCenter.PARAM_BASE_TYPE] = typeArgument.FullName;
                    param[NamingCenter.PARAM_TYPE_NAME] = typeArgument.FullName;
                    newTab.Content.Add(new IFrame()
                    {
                        Src = HttpHelper.BuildUrl(NamingCenter.CTRL_LIST_URL, param)
                    });
                    tab.TabItems.Add(newTab);
                }
                else if (typeof(IControl).IsAssignableFrom(p.PropertyType))
                {
                    var newItem = new TabItem()
                    {
                        Id       = p.Name,
                        TabName  = p.GetDisplayName(),
                        Visiable = true
                    };
                    param[NamingCenter.PARAM_TYPE_NAME] = p.PropertyType.FullName;
                    param[NamingCenter.PARAM_BASE_TYPE] = p.PropertyType.FullName;
                    newItem.Content.Add(new IFrame()
                    {
                        Src = HttpHelper.BuildUrl(NamingCenter.CTRL_SELECT_LIST_URL, param)
                    });
                    tab.TabItems.Add(newItem);
                }
                else
                {
                    continue;
                }
            }
            return(tab);
        }
示例#18
0
        public object GetSqlByExpression(Expression func)
        {
            switch (func.NodeType)
            {
            case ExpressionType.AndAlso:
            case ExpressionType.OrElse:
            case ExpressionType.Equal:
            case ExpressionType.GreaterThanOrEqual:
            case ExpressionType.LessThanOrEqual:
            case ExpressionType.GreaterThan:
            case ExpressionType.LessThan:
            case ExpressionType.NotEqual:
                var    exp = func as BinaryExpression;
                string left, right, op;
                bool   leftIsBinary  = exp.Left is BinaryExpression;
                bool   rightIsBinary = exp.Right is BinaryExpression;
                var    expLeft       = exp.Left;
                var    expRight      = exp.Right;
                op = GetOperator(exp.NodeType);
                if (!leftIsBinary && !rightIsBinary)
                {
                    if (expLeft is MethodCallExpression && expRight is MethodCallExpression)
                    {
                        left  = GetMemberCallValue(expLeft).ToString();
                        right = GetMemberCallValue(expRight).ToString();
                    }
                    else
                    {
                        if (expLeft.NodeType == ExpressionType.Convert)
                        {
                            expLeft = (expLeft as UnaryExpression).Operand;
                        }
                        if (expRight.NodeType == ExpressionType.Convert)
                        {
                            expRight = (expRight as UnaryExpression).Operand;
                        }
                        if (IsTargetTypeMember(expLeft))
                        {
                            GetLeftRight(expLeft, expRight, exp.NodeType, false, out left, out op, out right);
                        }
                        else if (IsTargetTypeMember(expRight))
                        {
                            GetLeftRight(expRight, expLeft, exp.NodeType, true, out left, out op, out right);
                        }
                        else
                        {
                            throw new Exception("不支持此表达式!");
                        }
                        left = Provider.EscapeIdentifier(left);
                    }
                }
                else
                {
                    left  = GetSqlByExpression(exp.Left).ToString();
                    right = GetSqlByExpression(exp.Right).ToString();
                }
                return("({0}{1}{2})".FormatTo(left, op, right));

            case ExpressionType.Constant:
                var exp3 = func as ConstantExpression;
                if (exp3.Value.ToString() == "True")
                {
                    return(" 1 = 1 ");
                }
                else if (exp3.Value.ToString() == "False")
                {
                    return(" 0 = 1 ");
                }
                else
                {
                    return(exp3.Value);
                }

            case ExpressionType.MemberAccess:
                var exp1 = func as MemberExpression;
                if (exp1.Expression == null)
                {
                    object value      = null;
                    var    isField    = exp1.Member is System.Reflection.FieldInfo;
                    var    isProperty = exp1.Member is System.Reflection.PropertyInfo;
                    if (isField)
                    {
                        value = GetFiledValue(exp1);
                    }
                    else if (isProperty)
                    {
                        value = GetPropertyValue(exp1);
                    }
                    return(value);
                }
                else
                {
                    if (exp1.Expression.NodeType == ExpressionType.Constant)
                    {
                        return(GetMemberValue(exp1.Member, exp1));
                    }
                    else if (exp1.Expression.NodeType == ExpressionType.MemberAccess)
                    {
                        string memberName = exp1.Member.Name;
                        object tempResult = GetSqlByExpression(exp1.Expression);
                        if (tempResult.GetType().IsClass&& tempResult.GetType() != typeof(string))
                        {
                            return(FastType.Get(tempResult.GetType()).GetGetter(memberName).GetValue(tempResult));
                        }
                        else
                        {
                            return(tempResult);
                        }
                    }
                    else
                    {
                        return(exp1.Member.Name);
                    }
                }

            case ExpressionType.Call:
                return(GetMemberCallValue(func));

            case ExpressionType.Not:
            case ExpressionType.Convert:
                var result = GetOperator(func.NodeType);
                return(result + GetSqlByExpression((func as UnaryExpression).Operand));

            default:
                throw new NotSupportedException("Not Suppost ExpressionType:" + func.NodeType.ToString());
            }
        }