示例#1
0
            private TableImportRestriction RestrictionToRestriction(ImportForeignSchemaInput request)
            {
                switch (request.RestrictionType)
                {
                case ImportForeignSchemaInput.Types.RestrictionType.None: return(TableImportRestriction.None);

                case ImportForeignSchemaInput.Types.RestrictionType.Limit: return(TableImportRestriction.Limit);

                case ImportForeignSchemaInput.Types.RestrictionType.Except: return(TableImportRestriction.Except);

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
示例#2
0
            public override async Task <ImportForeignSchemaOutput> ImportForeignSchema(ImportForeignSchemaInput request, ServerCallContext context)
            {
                var restriction = RestrictionToRestriction(request);

                var tables = await _importer.ImportTables(request.Schema, request.ServerOptions, request.ImportOptions, restriction, request.Restricted);

                var protoTables = tables.Select(table =>
                {
                    var options = table.Options.ToDictionary(
                        kvp => $"\"{kvp.Key}\"",
                        kvp => kvp.Value
                        );
                    options.Add("\"fdwsharp.table\"", table.Name);

                    return(new PostgresFdw.TableDefinition
                    {
                        Name = table.Name,
                        Columns = { table.Columns },
                        Options = { options },
                    });
                });

                return(new ImportForeignSchemaOutput {
                    Tables = { protoTables }
                });
            }