public static TableSelectionSet BuildFromString([CanBeNull] string filters)
        {
            var tableSelectionSet = new TableSelectionSet();
            if (string.IsNullOrWhiteSpace(filters))
            {
                return tableSelectionSet;
            }

            var filterSet = filters.Split(FilterSeparator, StringSplitOptions.RemoveEmptyEntries);
            foreach(var filterString in filterSet)
            {
                var filter = filterString;
                var exclude = false;
                if (filter.StartsWith(ExcludeIndicator, StringComparison.Ordinal))
                {
                    exclude = true;
                    filter = filter.Substring(1);
                }

                string schema = TableSelection.Any;
                string table = TableSelection.Any;
                var schemaTableIndex = filter.IndexOf(SchemaTableSeparator);
                if (schemaTableIndex > 0)
                {
                    schema = filter.Substring(0, schemaTableIndex);
                }
                table = filter.Substring(schemaTableIndex + 1);
                tableSelectionSet.AddSelections(
                    new TableSelection() { Schema = schema, Table = table, Exclude = exclude });
            }

            return tableSelectionSet;
        }
        public virtual IModel GenerateMetadataModel(
            [NotNull] string connectionString, [CanBeNull] TableSelectionSet tableSelectionSet)
        {
            Check.NotEmpty(connectionString, nameof(connectionString));

            _tableSelectionSet = tableSelectionSet ?? TableSelectionSet.InclusiveAll;

            var relationalModel = ConstructRelationalModel(connectionString);

            var nameMapper = GetNameMapper(relationalModel);

            var codeGenModel = ConstructCodeGenModel(relationalModel, nameMapper);
            return codeGenModel;
        }
示例#3
0
        public static TableSelectionSet BuildFromString([CanBeNull] string filters)
        {
            var tableSelectionSet = new TableSelectionSet();

            if (string.IsNullOrWhiteSpace(filters))
            {
                return(tableSelectionSet);
            }

            var filterSet = filters.Split(FilterSeparator, StringSplitOptions.RemoveEmptyEntries);

            foreach (var filterString in filterSet)
            {
                var filter  = filterString;
                var exclude = false;
                if (filter.StartsWith(ExcludeIndicator, StringComparison.Ordinal))
                {
                    exclude = true;
                    filter  = filter.Substring(1);
                }

                string schema           = TableSelection.Any;
                string table            = TableSelection.Any;
                var    schemaTableIndex = filter.IndexOf(SchemaTableSeparator);
                if (schemaTableIndex > 0)
                {
                    schema = filter.Substring(0, schemaTableIndex);
                }
                table = filter.Substring(schemaTableIndex + 1);
                tableSelectionSet.AddSelections(
                    new TableSelection()
                {
                    Schema = schema, Table = table, Exclude = exclude
                });
            }

            return(tableSelectionSet);
        }