Esempio n. 1
0
        public static TableMeta From(Type type)
        {
            return(cache.Get(type, () =>
            {
                var meta = new TableMeta(type);
                if (!meta.IsSimpleType())
                {
                    var columns = new List <ColumnMeta>();

                    foreach (var info in meta.Type.GetProperties(BindingFlags.Instance | BindingFlags.Public))
                    {
                        if (DbTypes.ContainsType(info.PropertyType) && !MapperConfig.IsIgnore(info, meta.Type))
                        {
                            columns.Add(new ColumnMeta(info, meta.Type));
                        }
                    }
                    foreach (var info in meta.Type.GetFields(BindingFlags.Instance | BindingFlags.Public))
                    {
                        if (DbTypes.ContainsType(info.FieldType) && !MapperConfig.IsIgnore(info, meta.Type))
                        {
                            columns.Add(new ColumnMeta(info, meta.Type));
                        }
                    }
                    meta.Columns = columns.AsReadOnly();
                }
                return meta;
            }));
        }
Esempio n. 2
0
 public TableConfig(Type type)
 {
     Type = type;
     foreach (var info in type.GetProperties(BindingFlags.Instance | BindingFlags.Public))
     {
         if (DbTypes.ContainsType(info.PropertyType))
         {
             Columns.Add(new ColumnConfig(info, type));
         }
     }
     foreach (var info in type.GetFields(BindingFlags.Instance | BindingFlags.Public))
     {
         if (DbTypes.ContainsType(info.FieldType))
         {
             Columns.Add(new ColumnConfig(info, type));
         }
     }
 }
Esempio n. 3
0
 public static bool IsSimpleType(Type type)
 {
     return(DbTypes.ContainsType(type) && type != typeof(object));
 }
Esempio n. 4
0
 public bool IsSimpleType()
 {
     return(DbTypes.ContainsType(Type) && Type != typeof(object));
 }