Beispiel #1
0
        private static async Task Step13TempTables(ISqDatabase database)
        {
            var tmp = new TempTable();

            var tableUser    = new TableUser();
            var tableCompany = new TableCompany();

            await database.Statement(tmp.Script.Create());

            //Users
            await InsertInto(tmp, tmp.Name)
            .From(Select(tableUser.FirstName + " " + tableUser.LastName)
                  .From(tableUser))
            .Exec(database);

            //Companies
            await InsertInto(tmp, tmp.Name)
            .From(Select(tableCompany.CompanyName)
                  .From(tableCompany))
            .Exec(database);

            await Select(tmp.Columns)
            .From(tmp)
            .OrderBy(tmp.Name)
            .Query(database,
                   r => Console.WriteLine($"Id: {tmp.Id.Read(r)}, Name: {tmp.Name.Read(r)}"));

            //Dropping the temp table is optional
            //It will be automatically removed when
            //the connection is closed
            await database.Statement(tmp.Script.Drop());
        }
Beispiel #2
0
        private static async Task Step1CreatingTables(ISqDatabase database)
        {
            var tables = CreateTableList();

            foreach (var table in tables.Reverse())
            {
                await database.Statement(table.Script.DropIfExist());
            }

            foreach (var table in tables)
            {
                await database.Statement(table.Script.Create());
            }
        }
Beispiel #3
0
        private static async Task Step1CreatingTables(ISqDatabase database)
        {
            var tables = new TableBase[]
            {
                new TableUser(),
                new TableCompany(),
                new TableCustomer(),
                new TableFavoriteFilter(),
                new TableFavoriteFilterItem()
            };

            foreach (var table in tables.Reverse())
            {
                await database.Statement(table.Script.DropIfExist());
            }

            foreach (var table in tables)
            {
                await database.Statement(table.Script.Create());
            }
        }