コード例 #1
0
        public List <FieldDefinitionAttribute> GetFilteringFields(string entityName)
        {
            EntityDefinition definition = new EntityDefinition();

            Type type = GetTypeofEntity(entityName);

            if (type == null)
            {
                return(null);
            }

            List <FieldDefinitionAttribute> list = new List <FieldDefinitionAttribute>();

            PropertyInfo[] props = type.GetProperties();
            foreach (PropertyInfo pi in props)
            {
                FieldDefinitionAttribute f = GenerateFieldDefinition(type, pi);
                if (f.IsFiltered)
                {
                    list.Add(f);
                }
            }

            return(list);
        }
コード例 #2
0
        private FieldDefinitionAttribute GenerateFieldDefinition(Type entityType, PropertyInfo property)
        {
            FieldDefinitionAttribute attr = null;

            //EntityFieldDefinition fieldDefinition = new EntityFieldDefinition();
            //fieldDefinition.Name = property.Name;

            if (property.Name != "Id")
            {
                attr = ReflectionHelper.GetAttribute <FieldDefinitionAttribute>(property);
            }
            else
            {
                attr = ReflectionHelper.GetAttribute <FieldDefinitionAttribute>(entityType);
            }

            if (attr != null)
            {
                attr.InstanceProperty = property;
            }
            else
            {
                attr = new FieldDefinitionAttribute(property);
            }

            return(attr);
        }
コード例 #3
0
ファイル: SchemaHelper.cs プロジェクト: noseii/powerscada2011
        private static string MapType(FieldDefinitionAttribute definition)
        {
            switch (definition.TypeName)
            {
                case "Byte":
                    return "tinyint";
                case "String":
                    return "varchar(" + definition.Length + ")";
                case "Int32":
                    return "int";
                case "Int64":
                    return "bigint";
                case "Boolean":
                    return "bit";
                case "Decimal":
                    return "decimal(18,4)";
                case "DateTime":
                    return "DateTime";
                case "Text":
                    return "ntext";
                case "Byte[]":

                    if(definition.Length==8000)
                        return "varbinary(MAX)";
                 return "varbinary(" + definition.Length + ")";
                case "nvarchar":
                    return "nvarchar(" + definition.Length + ")";
                default:
                    return "bigint"; //id field of foregin keys.
            }
        }
コード例 #4
0
ファイル: SchemaHelper.cs プロジェクト: noseii/powerscada2011
 private static string MapTypeMysql(FieldDefinitionAttribute definition)
 {
     switch (definition.TypeName)
     {
         case "String":
             return "nvarchar(" + definition.Length + ")";
         case "Int32":
             return "int";
         case "Boolean":
             return "tinyint(1)";
         case "Decimal":
             return "decimal(18,4)";
         case "DateTime":
             return "DateTime";
         default:
             return "bigint"; //id field of foregin keys.
     }
 }
コード例 #5
0
        private FieldDefinitionAttribute GenerateFieldDefinition(Type entityType, PropertyInfo property)
        {
            FieldDefinitionAttribute attr = null;
            //EntityFieldDefinition fieldDefinition = new EntityFieldDefinition();
            //fieldDefinition.Name = property.Name;

            if(property.Name != "Id")
                attr = ReflectionHelper.GetAttribute<FieldDefinitionAttribute>(property);
            else
                attr = ReflectionHelper.GetAttribute<FieldDefinitionAttribute>(entityType);

            if (attr != null)
            {
                attr.InstanceProperty = property;
            }
            else
            {
                attr = new FieldDefinitionAttribute(property);
            }

            return attr;
        }