Exemple #1
0
        private static void GetColumns(SchemaModel.Table table)
        {
            var flag       = false;
            var properties = table.Type.GetProperties();

            for (var i = 0; i < properties.Length; i++)
            {
                var column = ToColumn(properties[i]);
                column.Table = table;
                if (column.IsKey)
                {
                    flag      = true;
                    table.Key = column;
                }
                table.Columns.Add(column.PropertyInfo.Name, column);
            }
            if (!flag)
            {
                var column2 = table.Columns["id"]; // table.Columns<string, Column>("Id");
                if (column2 != null)
                {
                    column2.IsKey            = true;
                    column2.IsAutoIncreament = true;
                    column2.DataSourceType   = (DataSourceTypes)2;
                    table.Key = column2;
                }
            }
        }
Exemple #2
0
        private static SchemaModel.Table ToTable(Type entityType)
        {
            var table = _tableTypeMap[entityType];

            if (table == null)
            {
                var dictionary = _tableTypeMap;
                lock (dictionary)
                {
                    string name;
                    table = _tableTypeMap[entityType];
                    if (table != null)
                    {
                        return(table);
                    }
                    var attribute =
                        (TableAttribute)entityType.GetCustomAttributes(_tableAttrType, true).FirstOrDefault();
                    string str2 = null;
                    table = new SchemaModel.Table();
                    if (attribute != null)
                    {
                        name = attribute.Name;
                    }
                    else
                    {
                        name = BtCoreStringHelper.ToPlural(entityType.Name);
                    }
                    var attribute2 =
                        (DataBaseAttribute)
                        entityType.GetCustomAttributes(_dataBaseAttrType, true).FirstOrDefault();
                    if (attribute2 != null)
                    {
                        str2 = attribute2.Name;
                    }
                    table.DataBase = str2;
                    table.Name     = name;
                    table.Type     = entityType;
                    _tableTypeMap.Add(entityType, table);
                }
            }
            return(table);
        }
Exemple #3
0
 public abstract string GetTableName(SchemaModel.Table table);
        public static string GetTableName(SchemaModel.Table table)
        {
            var str = string.Empty;

            return(@"{str}[{table.Name}]");
        }