Ejemplo n.º 1
0
        private static void Initialize()
        {
            var tables = new List <Table.Table>();

            foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
            {
                foreach (Type type in assembly.GetTypes())
                {
                    var attribute = GetAttribute <TableAttribute>(type);

                    if (attribute != null)
                    {
                        var table = new Table.Table(type, attribute.Name);

                        SqlMapper.SetTypeMap(type, new CustomPropertyTypeMap(
                                                 type, (tp, columnName) =>
                                                 { return(table.ColumnByNameDB(columnName).PropertyInfo); }));

                        tables.Add(table);

                        _typeTables.Add(type, table);
                    }
                }
            }

            Tables = tables.ToArray();
        }