//
// 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 Microsoft.SqlTools.Utility;
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)
        {
            Logger.Verbose("Begin query Database");
            Server parentServer = context.Parent as Server;
            if (parentServer != null)
            {
                var retValue = parentServer.Databases;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<Database>(retValue).Where(c => PassesFinalFilters(parentServer, c));
                    Logger.Verbose("End query Database");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query LinkedServer");
            Server parentServer = context.Parent as Server;
            if (parentServer != null)
            {
                var retValue = parentServer.LinkedServers;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<LinkedServer>(retValue).Where(c => PassesFinalFilters(parentServer, c));
                    Logger.Verbose("End query LinkedServer");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query Login");
            Server parentServer = context.Parent as Server;
            if (parentServer != null)
            {
                var retValue = parentServer.Logins;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<Login>(retValue).Where(c => PassesFinalFilters(parentServer, c));
                    Logger.Verbose("End query Login");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query ServerRole");
            Server parentServer = context.Parent as Server;
            if (parentServer != null)
            {
                var retValue = parentServer.Roles;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<ServerRole>(retValue).Where(c => PassesFinalFilters(parentServer, c));
                    Logger.Verbose("End query ServerRole");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query Credential");
            Server parentServer = context.Parent as Server;
            if (parentServer != null)
            {
                var retValue = parentServer.Credentials;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<Credential>(retValue).Where(c => PassesFinalFilters(parentServer, c));
                    Logger.Verbose("End query Credential");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query CryptographicProvider");
            Server parentServer = context.Parent as Server;
            if (parentServer != null)
            {
                var retValue = parentServer.CryptographicProviders;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<CryptographicProvider>(retValue).Where(c => PassesFinalFilters(parentServer, c));
                    Logger.Verbose("End query CryptographicProvider");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query Audit");
            Server parentServer = context.Parent as Server;
            if (parentServer != null)
            {
                var retValue = parentServer.Audits;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<Audit>(retValue).Where(c => PassesFinalFilters(parentServer, c));
                    Logger.Verbose("End query Audit");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query ServerAuditSpecification");
            Server parentServer = context.Parent as Server;
            if (parentServer != null)
            {
                var retValue = parentServer.ServerAuditSpecifications;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<ServerAuditSpecification>(retValue).Where(c => PassesFinalFilters(parentServer, c));
                    Logger.Verbose("End query ServerAuditSpecification");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query Endpoint");
            Server parentServer = context.Parent as Server;
            if (parentServer != null)
            {
                var retValue = parentServer.Endpoints;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<Endpoint>(retValue).Where(c => PassesFinalFilters(parentServer, c));
                    Logger.Verbose("End query Endpoint");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query LinkedServer");
            Server parentServer = context.Parent as Server;
            if (parentServer != null)
            {
                var retValue = parentServer.LinkedServers;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<LinkedServer>(retValue).Where(c => PassesFinalFilters(parentServer, c));
                    Logger.Verbose("End query LinkedServer");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query ServerDdlTrigger");
            Server parentServer = context.Parent as Server;
            if (parentServer != null)
            {
                var retValue = parentServer.Triggers;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<ServerDdlTrigger>(retValue).Where(c => PassesFinalFilters(parentServer, c));
                    Logger.Verbose("End query ServerDdlTrigger");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query UserDefinedMessage");
            Server parentServer = context.Parent as Server;
            if (parentServer != null)
            {
                var retValue = parentServer.UserDefinedMessages;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<UserDefinedMessage>(retValue).Where(c => PassesFinalFilters(parentServer, c));
                    Logger.Verbose("End query UserDefinedMessage");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query Table");
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.Tables;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<Table>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                    Logger.Verbose("End query Table");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query Table");
            Table parentTable = context.Parent as Table;
            if (parentTable != null)
            {
                var retValue = parentTable.Parent.Tables;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<Table>(retValue).Where(c => PassesFinalFilters(parentTable, c));
                    Logger.Verbose("End query Table");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query View");
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.Views;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<View>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                    Logger.Verbose("End query View");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query Synonym");
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.Synonyms;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<Synonym>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                    Logger.Verbose("End query Synonym");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query Column");
            TableViewTableTypeBase parentTableViewTableTypeBase = context.Parent as TableViewTableTypeBase;
            if (parentTableViewTableTypeBase != null)
            {
                var retValue = parentTableViewTableTypeBase.Columns;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<Column>(retValue).Where(c => PassesFinalFilters(parentTableViewTableTypeBase, c));
                    Logger.Verbose("End query Column");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query Index");
            TableViewTableTypeBase parentTableViewTableTypeBase = context.Parent as TableViewTableTypeBase;
            if (parentTableViewTableTypeBase != null)
            {
                var retValue = parentTableViewTableTypeBase.Indexes;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<Index>(retValue).Where(c => PassesFinalFilters(parentTableViewTableTypeBase, c));
                    Logger.Verbose("End query Index");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query Check");
            Table parentTable = context.Parent as Table;
            if (parentTable != null)
            {
                var retValue = parentTable.Checks;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<Check>(retValue).Where(c => PassesFinalFilters(parentTable, c));
                    Logger.Verbose("End query Check");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query ForeignKey");
            Table parentTable = context.Parent as Table;
            if (parentTable != null)
            {
                var retValue = parentTable.ForeignKeys;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<ForeignKey>(retValue).Where(c => PassesFinalFilters(parentTable, c));
                    Logger.Verbose("End query ForeignKey");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query DefaultConstraint");
            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);
                        }
                    }
                    var ret = subFieldResult.Where(c => PassesFinalFilters(parentTable, c));
                    Logger.Verbose("End query DefaultConstraint");
                    return ret;
                }
            }
            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);
                        }
                    }
                    var ret = subFieldResult.Where(c => PassesFinalFilters(parentUserDefinedTableType, c));
                    Logger.Verbose("End query DefaultConstraint");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query Trigger");
            Table parentTable = context.Parent as Table;
            if (parentTable != null)
            {
                var retValue = parentTable.Triggers;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<Trigger>(retValue).Where(c => PassesFinalFilters(parentTable, c));
                    Logger.Verbose("End query Trigger");
                    return ret;
                }
            }
            View parentView = context.Parent as View;
            if (parentView != null)
            {
                var retValue = parentView.Triggers;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<Trigger>(retValue).Where(c => PassesFinalFilters(parentView, c));
                    Logger.Verbose("End query Trigger");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query FullTextIndex");
            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)
        {
            Logger.Verbose("Begin query Statistic");
            TableViewBase parentTableViewBase = context.Parent as TableViewBase;
            if (parentTableViewBase != null)
            {
                var retValue = parentTableViewBase.Statistics;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<Statistic>(retValue).Where(c => PassesFinalFilters(parentTableViewBase, c));
                    Logger.Verbose("End query Statistic");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query DatabaseDdlTrigger");
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.Triggers;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<DatabaseDdlTrigger>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                    Logger.Verbose("End query DatabaseDdlTrigger");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query SqlAssembly");
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.Assemblies;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<SqlAssembly>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                    Logger.Verbose("End query SqlAssembly");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query Sequence");
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.Sequences;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<Sequence>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                    Logger.Verbose("End query Sequence");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query UserDefinedDataType");
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.UserDefinedDataTypes;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<UserDefinedDataType>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                    Logger.Verbose("End query UserDefinedDataType");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query UserDefinedTableType");
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.UserDefinedTableTypes;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<UserDefinedTableType>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                    Logger.Verbose("End query UserDefinedTableType");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query XmlSchemaCollection");
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.XmlSchemaCollections;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<XmlSchemaCollection>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                    Logger.Verbose("End query XmlSchemaCollection");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query UserDefinedType");
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.UserDefinedTypes;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<UserDefinedType>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                    Logger.Verbose("End query UserDefinedType");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query UserDefinedFunction");
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.UserDefinedFunctions;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<UserDefinedFunction>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                    Logger.Verbose("End query UserDefinedFunction");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query UserDefinedAggregate");
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.UserDefinedAggregates;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<UserDefinedAggregate>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                    Logger.Verbose("End query UserDefinedAggregate");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query FileGroup");
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.FileGroups;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<FileGroup>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                    Logger.Verbose("End query FileGroup");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query DataFile");
            FileGroup parentFileGroup = context.Parent as FileGroup;
            if (parentFileGroup != null)
            {
                var retValue = parentFileGroup.Files;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<DataFile>(retValue).Where(c => PassesFinalFilters(parentFileGroup, c));
                    Logger.Verbose("End query DataFile");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query FullTextCatalog");
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.FullTextCatalogs;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<FullTextCatalog>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                    Logger.Verbose("End query FullTextCatalog");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query FullTextStopList");
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.FullTextStopLists;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<FullTextStopList>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                    Logger.Verbose("End query FullTextStopList");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query PartitionFunction");
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.PartitionFunctions;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<PartitionFunction>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                    Logger.Verbose("End query PartitionFunction");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query PartitionScheme");
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.PartitionSchemes;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<PartitionScheme>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                    Logger.Verbose("End query PartitionScheme");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query SearchPropertyList");
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.SearchPropertyLists;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<SearchPropertyList>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                    Logger.Verbose("End query SearchPropertyList");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query User");
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.Users;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<User>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                    Logger.Verbose("End query User");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query Schema");
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.Schemas;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<Schema>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                    Logger.Verbose("End query Schema");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query AsymmetricKey");
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.AsymmetricKeys;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<AsymmetricKey>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                    Logger.Verbose("End query AsymmetricKey");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query Certificate");
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.Certificates;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<Certificate>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                    Logger.Verbose("End query Certificate");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query SymmetricKey");
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.SymmetricKeys;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<SymmetricKey>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                    Logger.Verbose("End query SymmetricKey");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query DatabaseEncryptionKey");
            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)
        {
            Logger.Verbose("Begin query MasterKey");
            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)
        {
            Logger.Verbose("Begin query DatabaseAuditSpecification");
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.DatabaseAuditSpecifications;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<DatabaseAuditSpecification>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                    Logger.Verbose("End query DatabaseAuditSpecification");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query SecurityPolicy");
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.SecurityPolicies;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<SecurityPolicy>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                    Logger.Verbose("End query SecurityPolicy");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query DatabaseScopedCredential");
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.DatabaseScopedCredentials;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<DatabaseScopedCredential>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                    Logger.Verbose("End query DatabaseScopedCredential");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query DatabaseRole");
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.Roles;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<DatabaseRole>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                    Logger.Verbose("End query DatabaseRole");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query ApplicationRole");
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.ApplicationRoles;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<ApplicationRole>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                    Logger.Verbose("End query ApplicationRole");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query ColumnMasterKey");
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.ColumnMasterKeys;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<ColumnMasterKey>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                    Logger.Verbose("End query ColumnMasterKey");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query ColumnEncryptionKey");
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.ColumnEncryptionKeys;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<ColumnEncryptionKey>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                    Logger.Verbose("End query ColumnEncryptionKey");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query ServiceBroker");
            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)
        {
            Logger.Verbose("Begin query BrokerService");
            ServiceBroker parentServiceBroker = context.Parent as ServiceBroker;
            if (parentServiceBroker != null)
            {
                var retValue = parentServiceBroker.Services;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<BrokerService>(retValue).Where(c => PassesFinalFilters(parentServiceBroker, c));
                    Logger.Verbose("End query BrokerService");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query ServiceContract");
            ServiceBroker parentServiceBroker = context.Parent as ServiceBroker;
            if (parentServiceBroker != null)
            {
                var retValue = parentServiceBroker.ServiceContracts;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<ServiceContract>(retValue).Where(c => PassesFinalFilters(parentServiceBroker, c));
                    Logger.Verbose("End query ServiceContract");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query ServiceQueue");
            ServiceBroker parentServiceBroker = context.Parent as ServiceBroker;
            if (parentServiceBroker != null)
            {
                var retValue = parentServiceBroker.Queues;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<ServiceQueue>(retValue).Where(c => PassesFinalFilters(parentServiceBroker, c));
                    Logger.Verbose("End query ServiceQueue");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query RemoteServiceBinding");
            ServiceBroker parentServiceBroker = context.Parent as ServiceBroker;
            if (parentServiceBroker != null)
            {
                var retValue = parentServiceBroker.RemoteServiceBindings;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<RemoteServiceBinding>(retValue).Where(c => PassesFinalFilters(parentServiceBroker, c));
                    Logger.Verbose("End query RemoteServiceBinding");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query BrokerPriority");
            ServiceBroker parentServiceBroker = context.Parent as ServiceBroker;
            if (parentServiceBroker != null)
            {
                var retValue = parentServiceBroker.Priorities;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<BrokerPriority>(retValue).Where(c => PassesFinalFilters(parentServiceBroker, c));
                    Logger.Verbose("End query BrokerPriority");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query MessageType");
            ServiceBroker parentServiceBroker = context.Parent as ServiceBroker;
            if (parentServiceBroker != null)
            {
                var retValue = parentServiceBroker.MessageTypes;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<MessageType>(retValue).Where(c => PassesFinalFilters(parentServiceBroker, c));
                    Logger.Verbose("End query MessageType");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query ExternalDataSource");
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.ExternalDataSources;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<ExternalDataSource>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                    Logger.Verbose("End query ExternalDataSource");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query ExternalFileFormat");
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.ExternalFileFormats;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<ExternalFileFormat>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                    Logger.Verbose("End query ExternalFileFormat");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query StoredProcedure");
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.StoredProcedures;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<StoredProcedure>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                    Logger.Verbose("End query StoredProcedure");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query ExtendedStoredProcedure");
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.ExtendedStoredProcedures;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<ExtendedStoredProcedure>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                    Logger.Verbose("End query ExtendedStoredProcedure");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query Parameter");
            StoredProcedure parentStoredProcedure = context.Parent as StoredProcedure;
            if (parentStoredProcedure != null)
            {
                var retValue = parentStoredProcedure.Parameters;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<Parameter>(retValue).Where(c => PassesFinalFilters(parentStoredProcedure, c));
                    Logger.Verbose("End query Parameter");
                    return ret;
                }
            }
            UserDefinedAggregate parentUserDefinedAggregate = context.Parent as UserDefinedAggregate;
            if (parentUserDefinedAggregate != null)
            {
                var retValue = parentUserDefinedAggregate.Parameters;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<Parameter>(retValue).Where(c => PassesFinalFilters(parentUserDefinedAggregate, c));
                    Logger.Verbose("End query Parameter");
                    return ret;
                }
            }
            UserDefinedFunction parentUserDefinedFunction = context.Parent as UserDefinedFunction;
            if (parentUserDefinedFunction != null)
            {
                var retValue = parentUserDefinedFunction.Parameters;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<Parameter>(retValue).Where(c => PassesFinalFilters(parentUserDefinedFunction, c));
                    Logger.Verbose("End query Parameter");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query PartitionFunctionParameter");
            PartitionFunction parentPartitionFunction = context.Parent as PartitionFunction;
            if (parentPartitionFunction != null)
            {
                var retValue = parentPartitionFunction.PartitionFunctionParameters;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<PartitionFunctionParameter>(retValue).Where(c => PassesFinalFilters(parentPartitionFunction, c));
                    Logger.Verbose("End query PartitionFunctionParameter");
                    return ret;
                }
            }
            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)
        {
            Logger.Verbose("Begin query SystemDataType");
            Database parentDatabase = context.Parent as Database;
            if (parentDatabase != null)
            {
                var retValue = parentDatabase.Parent.SystemDataTypes;
                if (retValue != null)
                {
                    retValue.ClearAndInitialize(filter, extraProperties);
                    var ret = new SmoCollectionWrapper<SystemDataType>(retValue).Where(c => PassesFinalFilters(parentDatabase, c));
                    Logger.Verbose("End query SystemDataType");
                    return ret;
                }
            }
            return Enumerable.Empty<SqlSmoObject>();
        }
    }
}

