コード例 #1
0
        protected override void ProcessRecord()
        {
            if (this.Database != null)
            {
                _dbs.Add(this.Database);
            }

            else if (SmoContext.Databases != null && SmoContext.Databases.Count > 0)
            {
                _dbs.AddRange(SmoContext.Databases);
            }

            else
            {
                SmoContext.SetDatabases(_server.Databases);
                _dbs.AddRange(SmoContext.Databases);
            }
        }
コード例 #2
0
        protected override void ProcessRecord()
        {
            if (this.Database != null && this.MyInvocation.PipelinePosition >= 2)
            {
                if (this.HasNames())
                {
                    WildcardPattern[] patterns = this.PatternsFromNames(this.ViewName);
                    this.FilterByName(ref _views, patterns, this.Database);
                }
                else
                {
                    _views.AddRange(this.Database.Views);
                }
            }
            else if (this.Database != null && this.MyInvocation.PipelinePosition < 2)
            {
                NoEnd = true;
                if (this.HasNames())
                {
                    WildcardPattern[] patterns = base.PatternsFromNames(this.ViewName);
                    for (int i = 0; i < this.Database.Views.Count; i++)
                    {
                        View v = this.Database.Views[i];
                        if (base.NameMatchesPatterns(v.Name, patterns))
                        {
                            base.WriteObject(v);
                        }
                    }
                }
            }
            else
            {
                if (SmoContext.Databases == null)
                {
                    SmoContext.SetDatabases(_server.Databases);
                }

                _views.AddRange(SmoContext.Databases.SelectMany(x => x.Views.Cast <View>()));
            }
        }