Best NBi code snippet using NBi.Core.Analysis.Request.MetadataDiscoveryRequest
DiscoveryRequestFactory.cs
Source:DiscoveryRequestFactory.cs
...13 {14 validations.ForEach(v => v.Apply());15 }1617 public virtual MetadataDiscoveryRequest BuildDirect(string connectionString, DiscoveryTarget target, IEnumerable<IFilter> filters)18 {19 //Validations20 Validate( 21 new List<Validation>()22 {23 new ConnectionStringNotEmpty(connectionString),24 !target.Equals(DiscoveryTarget.Perspectives) ? (Validation)new PerspectiveNotNull(filters) : new NoValidation(),25 new MeasureGroupWithoutDimension(filters),26 new MeasureWithoutDimension(filters),27 new MeasureNotNull(filters),28 new DimensionNotNullIfHierarchy(target, filters),29 new HierarchyNotNullIfLevel(target, filters),30 new LevelNotNullIfProperty(target, filters),31 new TableNotNullIfColumn(target, filters)32 }33 );34 35 //If validation of parameters is successfull then we build the object36 var disco = new MetadataDiscoveryRequest(connectionString, target, filters);37 return disco;38 }3940 public virtual MembersDiscoveryRequest Build(string connectionString, string memberCaption, string perspective, string dimension, string hierarchy, string level)41 {42 return Build(connectionString, memberCaption, null, null, perspective, dimension, hierarchy, level);43 }4445 public virtual MembersDiscoveryRequest Build(string connectionString, string memberCaption46 , IEnumerable<string> excludedMembers47 , string perspective, string dimension, string hierarchy, string level)48 {49 return Build(connectionString, memberCaption, null, null, perspective, dimension, hierarchy, level);50 }5152 public virtual MembersDiscoveryRequest Build(string connectionString, string memberCaption53 , IEnumerable<string> excludedMembers, IEnumerable<PatternValue> excludedPatterns, 54 string perspective, string dimension, string hierarchy, string level)55 {56 //Validations57 Validate(58 new List<Validation>()59 {60 new ConnectionStringNotEmpty(connectionString),61 //new PerspectiveNotNull(perspective),62 //new DimensionNotNullIfHierarchy(dimension),63 //!string.IsNullOrEmpty(level) ? (Validation)new HierarchyNotNullIfLevel(hierarchy) : new NoValidation()64 }65 );6667 //If validation of parameters is successfull then we build the object68 var disco = new MembersDiscoveryRequest();69 disco.ConnectionString = connectionString;70 if (!string.IsNullOrEmpty(perspective)) disco.SpecifyFilter(new CaptionFilter(perspective, DiscoveryTarget.Perspectives));71 if (!string.IsNullOrEmpty(dimension)) disco.SpecifyFilter(new CaptionFilter(dimension, DiscoveryTarget.Dimensions));72 if (!string.IsNullOrEmpty(hierarchy)) disco.SpecifyFilter(new CaptionFilter(hierarchy, DiscoveryTarget.Hierarchies));73 if (!string.IsNullOrEmpty(level)) disco.SpecifyFilter(new CaptionFilter(level, DiscoveryTarget.Levels));74 disco.Function = string.IsNullOrEmpty(memberCaption) ? "members" : "children";75 disco.MemberCaption = memberCaption;76 disco.ExcludedMembers = excludedMembers;77 disco.ExcludedPatterns = excludedPatterns;7879 return disco;80 }8182 public virtual MetadataDiscoveryRequest BuildRelation(string connectionString, DiscoveryTarget target, IEnumerable<IFilter> filters)83 {84 //Validations85 Validate(86 new List<Validation>()87 {88 new ConnectionStringNotEmpty(connectionString),89 new PerspectiveNotNull(filters),90 new AtLeastOneNotNull(filters, DiscoveryTarget.Dimensions, DiscoveryTarget.MeasureGroups)91 }92 );9394 //If validation of parameters is successfull then we build the object95 var disco = new MetadataLinkedToDiscoveryRequest(connectionString, target, filters);96 return disco;
...
AdomdDiscoveryCommandFactory.cs
Source:AdomdDiscoveryCommandFactory.cs
...11 public AdomdDiscoveryCommandFactory()12 {13 }1415 public virtual AdomdDiscoveryCommand BuildExact(MetadataDiscoveryRequest request)16 {17 AdomdDiscoveryCommand cmd = null;1819 cmd = BuildBase(request.Target, request.ConnectionString);20 cmd.Filters = request.GetAllFilters();2122 return cmd;23 }2425 public virtual AdomdDiscoveryCommand BuildExternal(MetadataDiscoveryRequest request)26 {27 AdomdDiscoveryCommand cmd = null;2829 cmd = BuildBase(request.Target, request.ConnectionString);30 cmd.Filters = request.GetAllFilters().Where(f => f.Target!=request.Target);3132 return cmd;33 }3435 public virtual AdomdDiscoveryCommand BuildInternal(MetadataDiscoveryRequest request)36 {37 AdomdDiscoveryCommand cmd = null;3839 cmd = BuildBase(request.Target, request.ConnectionString);40 cmd.Filters = request.GetAllFilters().Where(f => f.Target == request.Target);4142 return cmd;43 }444546 public virtual AdomdDiscoveryCommand BuildLinkedTo(MetadataDiscoveryRequest request)47 {48 AdomdDiscoveryCommand cmd = null;4950 switch (request.Target)51 {52 case DiscoveryTarget.MeasureGroups:53 cmd= new DimensionLinkedToDiscoveryCommand(request.ConnectionString);54 break;55 case DiscoveryTarget.Dimensions:56 cmd= new MeasureGroupLinkedToDiscoveryCommand(request.ConnectionString);57 break;58 default:59 throw new ArgumentOutOfRangeException();60 }
...
AbstractStructureConstraint.cs
Source:AbstractStructureConstraint.cs
...22 23 /// <summary>24 /// Request for metadata extraction25 /// </summary>26 public MetadataDiscoveryRequest Request { get; protected set; }2728 /// <summary>29 /// Engine dedicated to MetadataExtractor acquisition30 /// </summary>31 protected internal AdomdDiscoveryCommandFactory CommandFactory32 {33 get34 {35 if (commandFactory == null)36 commandFactory = new AdomdDiscoveryCommandFactory();37 return commandFactory;38 }39 set40 {41 if (value == null)42 throw new ArgumentNullException();43 commandFactory = value;44 }45 }4647 /// <summary>48 /// Construct a CollectionContainsConstraint49 /// </summary>50 /// <param name="expected"></param>51 public AbstractStructureConstraint()52 {53 Comparer = new NBi.Core.Analysis.Metadata.Field.ComparerByCaption(true);54 }5556 #region Modifiers57 /// <summary>58 /// Flag the constraint to ignore case and return self.59 /// </summary>60 protected void IgnoreCase()61 {62 Comparer = new NBi.Core.Analysis.Metadata.Field.ComparerByCaption(false);63 }6465 #endregion66 67 #region Specific NUnit68 public override bool Matches(object actual)69 {70 if (actual is MetadataDiscoveryRequest)71 return Process((MetadataDiscoveryRequest)actual);72 else if (actual is IEnumerable<IField>)73 {74 this.actual = actual;75 var ctr = InternalConstraint;76 if (InternalConstraint is CollectionItemsEqualConstraint)77 //Only the type CollectionItemsEqualConstraint is supporting Using()78 //Others constraint are mostly a composition of constraints and the comparer is applied to each constraint.79 ctr = ((CollectionItemsEqualConstraint)ctr).Using(Comparer);80 var res = ctr.Matches(actual);81 return res;82 }83 else84 throw new ArgumentException();85 }8687 protected bool Process(MetadataDiscoveryRequest actual)88 {89 Request = actual;90 var factory = CommandFactory;91 var command = BuildCommand(factory,actual);92 IEnumerable<IField> structures = command.Execute();93 return this.Matches(structures);94 }9596 protected virtual AdomdDiscoveryCommand BuildCommand(AdomdDiscoveryCommandFactory factory, MetadataDiscoveryRequest actual)97 {98 return factory.BuildExact(actual);99 }100 #endregion101102 }103}
...
MetadataDiscoveryRequest
Using AI Code Generation
1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6using NBi.Core.Analysis.Request;7{8 {9 static void Main(string[] args)10 {11 MetadataDiscoveryRequest request = new MetadataDiscoveryRequest();12 request.ConnectionString = "Provider=MSOLAP.4;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Adventure Works DW Standard Edition;Data Source=Adventure Works";13 request.Catalog = "Adventure Works DW Standard Edition";14 request.Cube = "Adventure Works";15 request.CommandTimeout = 100;16 request.Discover();17 Console.WriteLine(request.MetadataXml);18 Console.ReadLine();19 }20 }21}22using System;23using System.Collections.Generic;24using System.Linq;25using System.Text;26using System.Threading.Tasks;27using NBi.Core.Analysis.Request;28{29 {30 static void Main(string[] args)31 {32 MetadataDiscoveryRequest request = new MetadataDiscoveryRequest();33 request.ConnectionString = "Provider=MSOLAP.4;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Adventure Works DW Standard Edition;Data Source=Adventure Works";34 request.Catalog = "Adventure Works DW Standard Edition";35 request.Cube = "Adventure Works";36 request.CommandTimeout = 100;37 request.Discover();38 Console.WriteLine(request.MetadataXml);39 Console.ReadLine();40 }41 }42}43using System;44using System.Collections.Generic;45using System.Linq;46using System.Text;47using System.Threading.Tasks;48using NBi.Core.Analysis.Request;49{50 {51 static void Main(string[] args)52 {53 MetadataDiscoveryRequest request = new MetadataDiscoveryRequest();54 request.ConnectionString = "Provider=MSOLAP.4;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Adventure Works DW Standard Edition;Data Source=Adventure Works";55 request.Catalog = "Adventure Works DW Standard Edition";56 request.Cube = "Adventure Works";57 request.CommandTimeout = 100;58 request.Discover();59 Console.WriteLine(request.MetadataXml);60 Console.ReadLine();61 }62 }63}
MetadataDiscoveryRequest
Using AI Code Generation
1using NBi.Core.Analysis.Request;2using NBi.Core.Analysis.Member;3using NBi.Core.Analysis.Metadata;4using System;5using System.Collections.Generic;6using System.Linq;7using System.Text;8using System.Threading.Tasks;9{10 {11 static void Main(string[] args)12 {13 var request = new MetadataDiscoveryRequest();14 request.CubeName = "Adventure Works";15 request.CommandTimeout = 60;16 var hierarchy = new HierarchyDiscoveryRequest();17 hierarchy.Caption = "Employee";18 hierarchy.UniqueName = "[Employee]";19 request.Hierarchies.Add(hierarchy);20 var level = new LevelDiscoveryRequest();21 level.Caption = "Employee";22 level.UniqueName = "[Employee].[Employee]";23 hierarchy.Levels.Add(level);24 var member = new MemberDiscoveryRequest();25 member.Caption = "All Employees";26 member.UniqueName = "[Employee].[Employee].[All Employees]";27 level.Members.Add(member);28 var metadata = new MetadataDiscovery();29 var result = metadata.Execute(request);30 Console.WriteLine(result.Hierarchies[0].Levels[0].Members[0].Caption);31 Console.ReadLine();32 }33 }34}35using NBi.Core.Analysis.Request;36using NBi.Core.Analysis.Member;37using NBi.Core.Analysis.Metadata;38using System;39using System.Collections.Generic;40using System.Linq;41using System.Text;42using System.Threading.Tasks;43{44 {45 static void Main(string[] args)46 {47 var request = new MetadataDiscoveryRequest();48 request.CubeName = "Adventure Works";49 request.CommandTimeout = 60;50 var hierarchy = new HierarchyDiscoveryRequest();51 hierarchy.Caption = "Employee";52 hierarchy.UniqueName = "[Employee]";
MetadataDiscoveryRequest
Using AI Code Generation
1using System;2 using System.Collections.Generic;3 using System.Linq;4 using System.Text;5 using System.Threading.Tasks;6 using NBi.Core.Analysis.Metadata;7 using NBi.Core.Analysis.Request;8 using NBi.Core.Analysis.Response;9{10 {11 static void Main( string [] args)12 {13 var request = new MetadataDiscoveryRequest();14 request.ConnectionString = @"Data Source=.\SQLExpress;Initial Catalog=AdventureWorks2012;Integrated Security=SSPI;" ;15 request.Command = new MetadataDiscoveryCommand();16 request.Command.MetadataType = MetadataDiscoveryCommand.MetadataTypes.Columns;17 request.Command.CollectionName = @"DimProduct" ;18 request.Command.Exclusions.Add( @"ProductSubcategoryID" );19 request.Command.Inclusions.Add( @"ProductID" );20 var response = request.Execute();21 Console.WriteLine(response.Columns.Count);22 Console.WriteLine(response.Columns[0].Caption);23 Console.WriteLine(response.Columns[0].UniqueName);24 Console.WriteLine(response.Columns[0].DataType);25 Console.WriteLine(response.Columns[0].Ordinal);26 Console.WriteLine(response.Columns[0].IsHidden);27 Console.WriteLine(response.Columns[0].IsCalculated);28 Console.WriteLine(response.Columns[0].IsKey);29 Console.WriteLine(response.Columns[0].IsMeasure);30 Console.ReadLine();31 }32 }33}
MetadataDiscoveryRequest
Using AI Code Generation
1MetadataDiscoveryRequest request = new MetadataDiscoveryRequest();2request.ConnectionString = "Data Source=.;Initial Catalog=AdventureWorks;Integrated Security=True";3request.CommandTimeout = 300;4MetadataDiscoveryResponse response = new MetadataDiscoveryResponse();5response = request.Execute();6Console.WriteLine("Tables: " + response.Tables.Count);7Console.WriteLine("Columns: " + response.Columns.Count);8Console.WriteLine("Hierarchies: " + response.Hierarchies.Count);9Console.WriteLine("Levels: " + response.Levels.Count);10Console.WriteLine("Measures: " + response.Measures.Count);11Console.WriteLine("Kpis: " + response.Kpis.Count);12Console.WriteLine("Members: " + response.Members.Count);13MetadataDiscoveryRequest request = new MetadataDiscoveryRequest();14request.ConnectionString = "Data Source=.;Initial Catalog=AdventureWorks;Integrated Security=True";15request.CommandTimeout = 300;16request.Tables.Add(new TableDiscoveryRequest("DimCustomer"));17request.Tables.Add(new TableDiscoveryRequest("DimProduct"));18MetadataDiscoveryResponse response = new MetadataDiscoveryResponse();19response = request.Execute();20Console.WriteLine("Tables: " + response.Tables.Count);21Console.WriteLine("Columns: " + response.Columns.Count);22Console.WriteLine("Hierarchies: " + response.Hierarchies.Count);23Console.WriteLine("Levels: " + response.Levels.Count);24Console.WriteLine("Measures: " + response.Measures.Count);25Console.WriteLine("Kpis: " + response.Kpis.Count);26Console.WriteLine("Members: " + response.Members.Count);27MetadataDiscoveryRequest request = new MetadataDiscoveryRequest();28request.ConnectionString = "Data Source=.;Initial Catalog=AdventureWorks;Integrated Security=True";29request.CommandTimeout = 300;30request.Tables.Add(new TableDiscoveryRequest("DimCustomer"));31request.Tables.Add(new TableDiscoveryRequest("DimProduct"));32request.Tables.Add(new TableDiscoveryRequest("Dim
MetadataDiscoveryRequest
Using AI Code Generation
1var request = new MetadataDiscoveryRequest();2request.ConnectionString = "Data Source=.;Initial Catalog=AdventureWorks2012;Integrated Security=SSPI;";3request.Catalog = "AdventureWorks2012";4request.Schema = "Sales";5request.Table = "Customer";6request.Type = MetadataDiscoveryRequestType.Columns;7var service = new MetadataDiscoveryService();8var response = service.Execute(request);9foreach (var column in response.Columns)10{11 Console.WriteLine(column.Name);12}13var request = new MetadataDiscoveryRequest();14request.ConnectionString = "Data Source=.;Initial Catalog=AdventureWorks2012;Integrated Security=SSPI;";15request.Catalog = "AdventureWorks2012";16request.Schema = "Sales";17request.Table = "Customer";18request.Type = MetadataDiscoveryRequestType.Columns;19var service = new MetadataDiscoveryService();20var response = service.Execute(request);21foreach (var column in response.Columns)22{23 Console.WriteLine(column.Name);24}25var request = new MetadataDiscoveryRequest();26request.ConnectionString = "Data Source=.;Initial Catalog=AdventureWorks2012;Integrated Security=SSPI;";27request.Catalog = "AdventureWorks2012";28request.Schema = "Sales";29request.Table = "Customer";30request.Type = MetadataDiscoveryRequestType.Columns;31var service = new MetadataDiscoveryService();32var response = service.Execute(request);33foreach (var column in response.Columns)34{35 Console.WriteLine(column.Name);36}37var request = new MetadataDiscoveryRequest();38request.ConnectionString = "Data Source=.;Initial Catalog=AdventureWorks2012;Integrated Security=SSPI;";39request.Catalog = "AdventureWorks2012";40request.Schema = "Sales";41request.Table = "Customer";42request.Type = MetadataDiscoveryRequestType.Columns;43var service = new MetadataDiscoveryService();44var response = service.Execute(request);45foreach (var column in response.Columns)46{47 Console.WriteLine(column.Name);48}49var request = new MetadataDiscoveryRequest();50request.ConnectionString = "Data Source=.;Initial Catalog=AdventureWorks2012;Integrated Security=SSPI;";
MetadataDiscoveryRequest
Using AI Code Generation
1using NBi.Core.Analysis.Request;2using NBi.Core.Analysis.Metadata;3using NBi.Core.Analysis.Request.Factory;4using NBi.Core.Analysis.Request.Factory.Ado;5using NBi.Core.Analysis.Request.Factory.Olap;6using NBi.Core.Analysis.Request.Factory.Rs;7using NBi.Core.Analysis.Request.Factory.Csv;8using NBi.Core.Analysis.Request.Factory.Xmla;9using NBi.Core.Analysis.Request.Factory.Json;10using NBi.Core.Analysis.Request.Factory.Excel;11using NBi.Core.Analysis.Request.Factory.Pivot;12using NBi.Core.Analysis.Request.Factory.Python;13using NBi.Core.Analysis.Request.Factory.Delimited;14using NBi.Core.Analysis.Request.Factory;15using NBi.Core.Analysis.Request.Factory;16using NBi.Core.Analysis.Request.Factory;17using NBi.Core.Analysis.Request.Factory;18{19 {20 public string ConnectionString { get; set; }21 public string Catalog { get; set; }22 public string Cube { get; set; }23 public string MeasureGroup { get; set; }24 public string Measure { get; set; }25 public string Column { get; set; }26 public string Hierarchy { get; set; }27 public string Level { get; set; }28 public string Kpi { get; set; }29 public string KpiGoal { get; set; }30 public string KpiStatus { get; set; }31 public string KpiTrend { get; set; }32 public string KpiWeight { get; set; }33 public string KpiValue { get; set; }34 public string Dimension { get; set; }35 public string Role { get; set; }36 public string Perspective { get; set; }37 public string PerspectiveCaption { get; set; }38 public string PerspectiveDefault { get; set; }39 public string PerspectiveVisible { get; set; }40 public string DimensionCaption { get; set; }41 public string DimensionDefault { get; set; }42 public string DimensionVisible { get; set; }43 public string HierarchyCaption { get; set; }44 public string HierarchyDefault { get; set; }45 public string HierarchyVisible { get; set; }46 public string LevelCaption { get; set; }47 public string LevelDefault { get
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!