//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//

// This file was generated by a T4 Template. Do not modify directly, instead update the SmoQueryModelDefinition.xml file
// and re-run the T4 template. This can be done in Visual Studio by right-click in and choosing "Run Custom Tool",
// or from the command-line on any platform by running "build.cmd -Target=CodeGen" or "build.sh -Target=CodeGen".

using System;
using System.Collections.Generic;
using System.Composition;
using System.Linq;
using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.Smo.Broker;
using Index = Microsoft.SqlServer.Management.Smo.Index;

namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
{

    [Export(typeof(SmoQuerier))]
    internal partial class SqlDatabaseQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(Database) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            Server parentServer = context.Parent as Server;
            if (parentServer != null)
            {
                var retValue = parentServer.Databases;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<Database>(retValue).Where(c => PassesFinalFilters(parentServer, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlLinkedServerLoginQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(LinkedServer) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            Server parentServer = context.Parent as Server;
            if (parentServer != null)
            {
                var retValue = parentServer.LinkedServers;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<LinkedServer>(retValue).Where(c => PassesFinalFilters(parentServer, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlLoginQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(Login) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            Server parentServer = context.Parent as Server;
            if (parentServer != null)
            {
                var retValue = parentServer.Logins;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<Login>(retValue).Where(c => PassesFinalFilters(parentServer, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlServerRoleQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(ServerRole) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            Server parentServer = context.Parent as Server;
            if (parentServer != null)
            {
                var retValue = parentServer.Roles;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<ServerRole>(retValue).Where(c => PassesFinalFilters(parentServer, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlCredentialQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(Credential) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            Server parentServer = context.Parent as Server;
            if (parentServer != null)
            {
                var retValue = parentServer.Credentials;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<Credential>(retValue).Where(c => PassesFinalFilters(parentServer, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlCryptographicProviderQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(CryptographicProvider) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            Server parentServer = context.Parent as Server;
            if (parentServer != null)
            {
                var retValue = parentServer.CryptographicProviders;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<CryptographicProvider>(retValue).Where(c => PassesFinalFilters(parentServer, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlServerAuditQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(Audit) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            Server parentServer = context.Parent as Server;
            if (parentServer != null)
            {
                var retValue = parentServer.Audits;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<Audit>(retValue).Where(c => PassesFinalFilters(parentServer, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlServerAuditSpecificationQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(ServerAuditSpecification) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            Server parentServer = context.Parent as Server;
            if (parentServer != null)
            {
                var retValue = parentServer.ServerAuditSpecifications;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<ServerAuditSpecification>(retValue).Where(c => PassesFinalFilters(parentServer, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlEndpointQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(Endpoint) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            Server parentServer = context.Parent as Server;
            if (parentServer != null)
            {
                var retValue = parentServer.Endpoints;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<Endpoint>(retValue).Where(c => PassesFinalFilters(parentServer, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlLinkedServerQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(LinkedServer) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            Server parentServer = context.Parent as Server;
            if (parentServer != null)
            {
                var retValue = parentServer.LinkedServers;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<LinkedServer>(retValue).Where(c => PassesFinalFilters(parentServer, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlServerDdlTriggerQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(ServerDdlTrigger) };

        public override ValidForFlag ValidFor { get { return ValidForFlag.NotSqlDw; } }


        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            Server parentServer = context.Parent as Server;
            if (parentServer != null)
            {
                var retValue = parentServer.Triggers;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<ServerDdlTrigger>(retValue).Where(c => PassesFinalFilters(parentServer, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlErrorMessageQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(UserDefinedMessage) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            Server parentServer = context.Parent as Server;
            if (parentServer != null)
            {
                var retValue = parentServer.UserDefinedMessages;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<UserDefinedMessage>(retValue).Where(c => PassesFinalFilters(parentServer, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlTableQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(Table) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.Tables;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<Table>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlHistoryTableQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(Table) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            Table parentTable = context.Parent as Table;
            if (parentTable != null)
            {
                var retValue = parentTable.Parent.Tables;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<Table>(retValue).Where(c => PassesFinalFilters(parentTable, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlViewQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(View) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.Views;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<View>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlSynonymQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(Synonym) };

        public override ValidForFlag ValidFor { get { return ValidForFlag.NotSqlDw; } }


        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.Synonyms;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<Synonym>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlColumnQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(Column) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            TableViewTableTypeBase parentTableViewTableTypeBase = context.Parent as TableViewTableTypeBase;
            if (parentTableViewTableTypeBase != null)
            {
                var retValue = parentTableViewTableTypeBase.Columns;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<Column>(retValue).Where(c => PassesFinalFilters(parentTableViewTableTypeBase, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlIndexQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(Index) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            TableViewTableTypeBase parentTableViewTableTypeBase = context.Parent as TableViewTableTypeBase;
            if (parentTableViewTableTypeBase != null)
            {
                var retValue = parentTableViewTableTypeBase.Indexes;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<Index>(retValue).Where(c => PassesFinalFilters(parentTableViewTableTypeBase, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlCheckQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(Check) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            Table parentTable = context.Parent as Table;
            if (parentTable != null)
            {
                var retValue = parentTable.Checks;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<Check>(retValue).Where(c => PassesFinalFilters(parentTable, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlForeignKeyConstraintQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(ForeignKey) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            Table parentTable = context.Parent as Table;
            if (parentTable != null)
            {
                var retValue = parentTable.ForeignKeys;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<ForeignKey>(retValue).Where(c => PassesFinalFilters(parentTable, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlDefaultConstraintQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(DefaultConstraint) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            Table parentTable = context.Parent as Table;
            if (parentTable != null)
            {
                var retValue = parentTable.Columns;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    List<DefaultConstraint> subFieldResult = new List<DefaultConstraint>();
                    foreach(Column field in retValue)
                    {
                        DefaultConstraint subField = field.DefaultConstraint;
                        if (subField != null)
                        {
                            subFieldResult.Add(subField);
                        }
                    }
                    return subFieldResult.Where(c => PassesFinalFilters(parentTable, c));
                }
            }
            UserDefinedTableType parentUserDefinedTableType = context.Parent as UserDefinedTableType;
            if (parentUserDefinedTableType != null)
            {
                var retValue = parentUserDefinedTableType.Columns;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    List<DefaultConstraint> subFieldResult = new List<DefaultConstraint>();
                    foreach(Column field in retValue)
                    {
                        DefaultConstraint subField = field.DefaultConstraint;
                        if (subField != null)
                        {
                            subFieldResult.Add(subField);
                        }
                    }
                    return subFieldResult.Where(c => PassesFinalFilters(parentUserDefinedTableType, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlDmlTriggerQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(Trigger) };

        public override ValidForFlag ValidFor { get { return ValidForFlag.NotSqlDw; } }


        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            Table parentTable = context.Parent as Table;
            if (parentTable != null)
            {
                var retValue = parentTable.Triggers;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<Trigger>(retValue).Where(c => PassesFinalFilters(parentTable, c));
                }
            }
            View parentView = context.Parent as View;
            if (parentView != null)
            {
                var retValue = parentView.Triggers;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<Trigger>(retValue).Where(c => PassesFinalFilters(parentView, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlFullTextIndexQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(FullTextIndex) };

        public override ValidForFlag ValidFor { get { return ValidForFlag.NotSqlDw; } }


        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            Table parentTable = context.Parent as Table;
            if (parentTable != null)
            {
                var retValue = parentTable.FullTextIndex;
                if (retValue != null)
                {
                    if (refresh)
                    {
                        parentTable.FullTextIndex.Refresh();
                    }
                    return new SqlSmoObject[] { retValue };
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlStatisticQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(Statistic) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            TableViewBase parentTableViewBase = context.Parent as TableViewBase;
            if (parentTableViewBase != null)
            {
                var retValue = parentTableViewBase.Statistics;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<Statistic>(retValue).Where(c => PassesFinalFilters(parentTableViewBase, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlDatabaseDdlTriggerQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(DatabaseDdlTrigger) };

        public override ValidForFlag ValidFor { get { return ValidForFlag.NotSqlDw; } }


        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.Triggers;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<DatabaseDdlTrigger>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlAssemblyQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(SqlAssembly) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.Assemblies;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<SqlAssembly>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlSequenceQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(Sequence) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.Sequences;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<Sequence>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlUserDefinedDataTypeQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(UserDefinedDataType) };

        public override ValidForFlag ValidFor { get { return ValidForFlag.NotSqlDw; } }


        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.UserDefinedDataTypes;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<UserDefinedDataType>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlUserDefinedTableTypeQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(UserDefinedTableType) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.UserDefinedTableTypes;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<UserDefinedTableType>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlXmlSchemaCollectionQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(XmlSchemaCollection) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.XmlSchemaCollections;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<XmlSchemaCollection>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlUserDefinedTypeQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(UserDefinedType) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.UserDefinedTypes;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<UserDefinedType>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlUserDefinedFunctionQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(UserDefinedFunction) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.UserDefinedFunctions;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<UserDefinedFunction>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlUserDefinedAggregateQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(UserDefinedAggregate) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.UserDefinedAggregates;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<UserDefinedAggregate>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlFileGroupQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(FileGroup) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.FileGroups;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<FileGroup>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlFileQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(DataFile) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            FileGroup parentFileGroup = context.Parent as FileGroup;
            if (parentFileGroup != null)
            {
                var retValue = parentFileGroup.Files;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<DataFile>(retValue).Where(c => PassesFinalFilters(parentFileGroup, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlFullTextCatalogQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(FullTextCatalog) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.FullTextCatalogs;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<FullTextCatalog>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlFullTextStopListQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(FullTextStopList) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.FullTextStopLists;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<FullTextStopList>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlPartitionFunctionQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(PartitionFunction) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.PartitionFunctions;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<PartitionFunction>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlPartitionSchemeQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(PartitionScheme) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.PartitionSchemes;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<PartitionScheme>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlSearchPropertyListQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(SearchPropertyList) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.SearchPropertyLists;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<SearchPropertyList>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlUserQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(User) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.Users;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<User>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlSchemaQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(Schema) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.Schemas;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<Schema>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlAsymmetricKeyQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(AsymmetricKey) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.AsymmetricKeys;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<AsymmetricKey>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlCertificateQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(Certificate) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.Certificates;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<Certificate>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlSymmetricKeyQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(SymmetricKey) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.SymmetricKeys;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<SymmetricKey>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlDatabaseEncryptionKeyQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(DatabaseEncryptionKey) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.DatabaseEncryptionKey;
                if (retValue != null)
                {
                    if (refresh)
                    {
                        parentDatabase.DatabaseEncryptionKey.Refresh();
                    }
                    return new SqlSmoObject[] { retValue };
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlMasterKeyQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(MasterKey) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.MasterKey;
                if (retValue != null)
                {
                    if (refresh)
                    {
                        parentDatabase.MasterKey.Refresh();
                    }
                    return new SqlSmoObject[] { retValue };
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlDatabaseAuditSpecificationQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(DatabaseAuditSpecification) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.DatabaseAuditSpecifications;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<DatabaseAuditSpecification>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlSecurityPolicyQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(SecurityPolicy) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.SecurityPolicies;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<SecurityPolicy>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlDatabaseCredentialQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(DatabaseScopedCredential) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.DatabaseScopedCredentials;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<DatabaseScopedCredential>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlRoleQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(DatabaseRole) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.Roles;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<DatabaseRole>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlApplicationRoleQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(ApplicationRole) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.ApplicationRoles;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<ApplicationRole>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlColumnMasterKeyQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(ColumnMasterKey) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.ColumnMasterKeys;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<ColumnMasterKey>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlColumnEncryptionKeyQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(ColumnEncryptionKey) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.ColumnEncryptionKeys;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<ColumnEncryptionKey>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlServiceBrokerQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(ServiceBroker) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.ServiceBroker;
                if (retValue != null)
                {
                    if (refresh)
                    {
                        parentDatabase.ServiceBroker.Refresh();
                    }
                    return new SqlSmoObject[] { retValue };
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlServiceQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(BrokerService) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            ServiceBroker parentServiceBroker = context.Parent as ServiceBroker;
            if (parentServiceBroker != null)
            {
                var retValue = parentServiceBroker.Services;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<BrokerService>(retValue).Where(c => PassesFinalFilters(parentServiceBroker, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlContractQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(ServiceContract) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            ServiceBroker parentServiceBroker = context.Parent as ServiceBroker;
            if (parentServiceBroker != null)
            {
                var retValue = parentServiceBroker.ServiceContracts;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<ServiceContract>(retValue).Where(c => PassesFinalFilters(parentServiceBroker, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlQueueQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(ServiceQueue) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            ServiceBroker parentServiceBroker = context.Parent as ServiceBroker;
            if (parentServiceBroker != null)
            {
                var retValue = parentServiceBroker.Queues;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<ServiceQueue>(retValue).Where(c => PassesFinalFilters(parentServiceBroker, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlRemoteServiceBindingQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(RemoteServiceBinding) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            ServiceBroker parentServiceBroker = context.Parent as ServiceBroker;
            if (parentServiceBroker != null)
            {
                var retValue = parentServiceBroker.RemoteServiceBindings;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<RemoteServiceBinding>(retValue).Where(c => PassesFinalFilters(parentServiceBroker, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlBrokerPriorityQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(BrokerPriority) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            ServiceBroker parentServiceBroker = context.Parent as ServiceBroker;
            if (parentServiceBroker != null)
            {
                var retValue = parentServiceBroker.Priorities;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<BrokerPriority>(retValue).Where(c => PassesFinalFilters(parentServiceBroker, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlMessageTypeQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(MessageType) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            ServiceBroker parentServiceBroker = context.Parent as ServiceBroker;
            if (parentServiceBroker != null)
            {
                var retValue = parentServiceBroker.MessageTypes;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<MessageType>(retValue).Where(c => PassesFinalFilters(parentServiceBroker, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlExternalDataSourceQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(ExternalDataSource) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.ExternalDataSources;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<ExternalDataSource>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlExternalFileFormatQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(ExternalFileFormat) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.ExternalFileFormats;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<ExternalFileFormat>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlProcedureQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(StoredProcedure) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.StoredProcedures;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<StoredProcedure>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlExtendedStoredProcedureQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(ExtendedStoredProcedure) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.ExtendedStoredProcedures;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<ExtendedStoredProcedure>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlSubroutineParameterQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(Parameter) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            StoredProcedure parentStoredProcedure = context.Parent as StoredProcedure;
            if (parentStoredProcedure != null)
            {
                var retValue = parentStoredProcedure.Parameters;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<Parameter>(retValue).Where(c => PassesFinalFilters(parentStoredProcedure, c));
                }
            }
            UserDefinedAggregate parentUserDefinedAggregate = context.Parent as UserDefinedAggregate;
            if (parentUserDefinedAggregate != null)
            {
                var retValue = parentUserDefinedAggregate.Parameters;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<Parameter>(retValue).Where(c => PassesFinalFilters(parentUserDefinedAggregate, c));
                }
            }
            UserDefinedFunction parentUserDefinedFunction = context.Parent as UserDefinedFunction;
            if (parentUserDefinedFunction != null)
            {
                var retValue = parentUserDefinedFunction.Parameters;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<Parameter>(retValue).Where(c => PassesFinalFilters(parentUserDefinedFunction, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlPartitionFunctionParameterQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(PartitionFunctionParameter) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            PartitionFunction parentPartitionFunction = context.Parent as PartitionFunction;
            if (parentPartitionFunction != null)
            {
                var retValue = parentPartitionFunction.PartitionFunctionParameters;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<PartitionFunctionParameter>(retValue).Where(c => PassesFinalFilters(parentPartitionFunction, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }

    [Export(typeof(SmoQuerier))]
    internal partial class SqlBuiltInTypeQuerier: SmoQuerier
    {
        Type[] supportedTypes = new Type[] { typeof(SystemDataType) };

        public override Type[] SupportedObjectTypes { get { return supportedTypes; } }

        public override  IEnumerable<SqlSmoObject> Query(SmoQueryContext context, string filter, bool refresh, IEnumerable<string> extraProperties)
        {
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.Parent.SystemDataTypes;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    return new SmoCollectionWrapper<SystemDataType>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }
}

