private async Task <bool> CheckIndexExistsAsync(string tableName, string field)
        {
            return(await Task.Run(async() =>
            {
                Amazon.QLDB.Driver.IAsyncResult result = await qldbDriver.Execute(async transactionExecutor =>
                {
                    IIonValue ionTableName = this.valueFactory.NewString(tableName);
                    return await transactionExecutor.Execute($"SELECT * FROM information_schema.user_tables WHERE name = ?", ionTableName);
                });

                List <IIonValue> ionValues = await result.ToListAsync();
                if (ionValues.Any())
                {
                    IIonList indexes = ionValues.First().GetField("indexes");
                    foreach (IIonValue index in indexes)
                    {
                        string expr = index.GetField("expr").StringValue;
                        if (expr.Contains(field))
                        {
                            return true;
                        }
                    }
                }

                return false;
            }));
        }
示例#2
0
        public async Task Run()
        {
            await Task.Run(async() =>
            {
                await DeleteDataFromTable(VehicleTableName);
                await InsertVehicles();

                await DeleteDataFromTable(PersonTableName);
                Amazon.QLDB.Driver.IAsyncResult insertPeopleResult = await InsertPeople();
                List <string> peopleDocumentIds = await insertPeopleResult.Select(x => x.GetField("documentId").StringValue).ToListAsync();

                await DeleteDataFromTable(DriversLicenseTableName);
                await InsertDriversLicenses(peopleDocumentIds);

                await DeleteDataFromTable(VehicleRegistrationTableName);
                await InsertVehicleRegistrations(peopleDocumentIds);
            });
        }