Exemple #1
0
        public Table Get(Database database, string schema, string name)
        {
            Table table;

            using (var db = getDbConnection.Get(database)) {
                table = db.QueryFirst <Table>(Get(schema, name));
            }
            table.Database       = database;
            table.Columns        = listTableColumn.List(table);
            table.IdentityColumn = (from item in table.Columns where item.IsIdentity select item).FirstOrDefault();
            var indexes = listTableIndex.List(table);

            table.PrimaryKeys = (from index in indexes where index.IsPrimaryKey select index).FirstOrDefault()?.Columns;
            return(table);
        }
Exemple #2
0
        public IEnumerable <Table> Get(Database database, string criteria)
        {
            IEnumerable <Table> tables;
            string schema, name;

            parseCriteria.Parse(criteria, out schema, out name);
            using (var db = getDbConnection.Get(database)) {
                tables = db.Query <Table>(Get(schema, name));
            }
            foreach (var table in tables)
            {
                table.Database       = database;
                table.Columns        = listTableColumn.List(table);
                table.IdentityColumn = (from item in table.Columns where item.IsIdentity select item).FirstOrDefault();
                var indexes = listTableIndex.List(table);
                table.PrimaryKeys = (from index in indexes where index.IsPrimaryKey select index).FirstOrDefault()?.Columns;
            }
            return(tables);
        }