Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 3
0
        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.
            }
        }
Exemplo n.º 4
0
 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.
     }
 }
Exemplo n.º 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;
        }