Best NBi code snippet using NBi.Core.Analysis.Member.MembersCommand.Build
MembersCommand.cs
Source:MembersCommand.cs
...87 Inform("Investigating members");8889 using (var cmd = CreateCommand())90 {91 var path = BuildPath(filters);92 var perspective = GetPerspective(filters);93 var commandText = Build(perspective.Value, path, Function, MemberCaption, ExcludedMembers, ExcludedPatterns);94 cmd.CommandText = commandText;95 if (!(cmd is AdomdCommand))96 throw new NotImplementedException();97 var cs = ExecuteCellSet(cmd as AdomdCommand);98 // Traverse the response (The response is on first line!!!) 99 var i = 0;100 foreach (var position in cs.Axes[1].Positions)101 {102 var member = position.Members[0];103 var uniqueName = member.UniqueName;104 var caption = member.Caption;105 var ordinal = ++i;106 var levelNumber = member.LevelDepth;107108 list.Add(new Member(uniqueName, caption, ordinal, levelNumber));109 }110 }111112 Inform("Members investigated");113114 return list;115 }116 117 private CaptionFilter GetPerspective(IEnumerable<IFilter> filters)118 {119 var perFilter = FindFilterOrNull(filters, DiscoveryTarget.Perspectives);120 return perFilter;121 }122123 private string BuildPath(IEnumerable<IFilter> filters)124 {125 var setFilter = FindFilterOrNull(filters, DiscoveryTarget.Sets);126 if (setFilter != null)127 return string.Format("[{0}]", setFilter.Value);128129 var dimFilter = FindFilterOrNull(filters, DiscoveryTarget.Dimensions);130131 var hieFilter = FindFilterOrNull(filters, DiscoveryTarget.Hierarchies);132 if (hieFilter == null)133 return string.Format("[{0}]", dimFilter.Value);134 135 var levFilter = FindFilterOrNull(filters, DiscoveryTarget.Levels);136 if (levFilter == null)137 return string.Format("[{0}].[{1}]", dimFilter.Value, hieFilter.Value);138 else139 return string.Format("[{0}].[{1}].[{2}]", dimFilter.Value, hieFilter.Value, levFilter.Value);140 }141142 protected CaptionFilter FindFilterOrNull(IEnumerable<IFilter> filters, DiscoveryTarget target)143 {144 var filter = filters.FirstOrDefault(f => f is CaptionFilter && ((CaptionFilter)f).Target == target);145 return (CaptionFilter)filter;146 }147148 public string Build(string perspective, string path, string function, string memberCaption)149 {150 return Build(perspective, path, function,memberCaption, null, null);151 }152153 public string Build(string perspective, string path, string function, string memberCaption, IEnumerable<string> exludedMembers, IEnumerable<PatternValue> excludedPatterns)154 {155 var members = string.Empty;156 if (string.IsNullOrEmpty(function))157 members = string.Format("{0}", path);158 else if (string.IsNullOrEmpty(memberCaption))159 members = string.Format("{0}.{1}", path, function);160 else161 members = string.Format("{0}.[{2}].{1}", path, function, memberCaption);162163 if (exludedMembers!=null && exludedMembers.Count()>0)164 {165 foreach (var excl in exludedMembers)166 members = string.Format("{0}-{1}.[{2}]", members, path, excl);167 members = string.Format("{0}{1}{2}", "{", members, "}");168 }169170 if (ExcludedPatterns != null && ExcludedPatterns.Count() > 0)171 {172 var hierarchyPath = BuildHierarchyPath(path);173 var exclPattern = BuildExcludedPatterns(hierarchyPath, excludedPatterns);174 members = string.Format("filter({0}, {1})"175 , members176 , exclPattern); 177 }178 179 var commandText = string.Empty;180 commandText = string.Format("select {0} on 0, {1} on 1 from [{2}]", "{}", members, perspective);181182 Trace.WriteLineIf(Extensibility.NBiTraceSwitch.TraceInfo, commandText);183 return commandText;184 }185186 private string BuildHierarchyPath(string path)187 {188 if (path.Count(c => c == '.') == 1)189 return path;190 else191 return path.Substring(0,path.IndexOf('.', path.IndexOf('.') + 1));192 }193194 internal protected string BuildExcludedPatterns(string hierarchyPath, IEnumerable<PatternValue> excludedPatterns)195 {196 if (excludedPatterns == null || excludedPatterns.Count() == 0)197 return string.Empty;198199 var exclusions = new System.Text.StringBuilder();200 foreach (var excl in excludedPatterns)201 {202 var exclPattern = string.Empty;203 switch (excl.Pattern)204 {205 case Pattern.StartWith:206 exclPattern = "left({0}, len('{1}'))<>'{1}'";207 break;208 case Pattern.EndWith:209 exclPattern = "right({0}, len('{1}'))<>'{1}'";210 break;211 case Pattern.Exact:212 exclPattern = "{0}<>'{1}'";213 break;
...
Build
Using AI Code Generation
1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6using NBi.Core.Analysis.Member;7using NBi.Core.Analysis.Request;8using NBi.Core.Analysis.Metadata.Adomd;9{10 {11 static void Main(string[] args)12 {13 var membersCommand = new MembersCommand(new AdomdMetadataDiscoveryCommand(new AdomdConnectionStringBuilder("Provider=MSOLAP.4;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Adventure Works DW Standard Edition;Data Source=AdventureWorksDW2012"), "Adventure Works DW Standard Edition"));14 var request = new MembersRequest();15 request.HierarchyUniqueName = "[Date].[Fiscal]";16 request.MemberUniqueName = "[Date].[Fiscal].[Fiscal Year]";17 request.MemberType = MemberType.Leaf;18 var result = membersCommand.Execute(request);19 foreach (var item in result)20 {21 Console.WriteLine(item);22 }23 Console.ReadLine();24 }25 }26}27using System;28using System.Collections.Generic;29using System.Linq;30using System.Text;31using System.Threading.Tasks;32using NBi.Core.Analysis.Member;33using NBi.Core.Analysis.Request;34using NBi.Core.Analysis.Metadata.Adomd;35{36 {37 static void Main(string[] args)38 {39 var membersCommand = new MembersCommand(new AdomdMetadataDiscoveryCommand(new AdomdConnectionString
Build
Using AI Code Generation
1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6using NBi.Core.Analysis.Member;7using NBi.Core.Analysis.Request;8using NBi.Core.Analysis.Member.Builders;9using NBi.Core.Analysis.Member.Resolver;10{11 {12 static void Main(string[] args)13 {14 var membersCommand = new MembersCommand(new CaptionFilter("Product"));15 var request = new DiscoveryRequest();16 request.MembersCommands.Add(membersCommand);17 var builder = new InMemoryBuilder();18 builder.Setup(new[] { "Product", "Year" });19 builder.AddRow(new[] { "Bike", "2010" });20 builder.AddRow(new[] { "Bike", "2011" });21 builder.AddRow(new[] { "Bike", "2012" });22 builder.AddRow(new[] { "Bike", "2013" });23 builder.AddRow(new[] { "Bike", "2014" });24 builder.AddRow(new[] { "Car", "2010" });25 builder.AddRow(new[] { "Car", "2011" });26 builder.AddRow(new[] { "Car", "2012" });27 builder.AddRow(new[] { "Car", "2013" });28 builder.AddRow(new[] { "Car", "2014" });29 builder.AddRow(new[] { "Truck", "2010" });30 builder.AddRow(new[] { "Truck", "2011" });31 builder.AddRow(new[] { "Truck", "2012" });32 builder.AddRow(new[] { "Truck", "2013" });33 builder.AddRow(new[] { "Truck", "2014" });34 var resolver = new InMemoryResolver(builder.GetDiscoveryResult());35 resolver.Setup(request);36 var result = resolver.Execute();37 foreach (var member in result)38 {39 Console.WriteLine(member.Caption);40 }41 Console.ReadLine();42 }43 }44}
Build
Using AI Code Generation
1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using NBi.Core.Analysis.Member;6using NBi.Core.Analysis.Request;7using NBi.Core.Analysis.Metadata;8using NBi.Core.Analysis.Member.Rewriter;9using NBi.Core.Analysis.Member.Resolver;10using NBi.Core.Analysis.Member.Builders;11using NBi.Core.Analysis.Member.Builders.Comparer;12using NBi.Core.Analysis.Member.Builders.Comparer.Strategy;13using NBi.Core.Analysis.Member.Builders.Comparer.Strategy.Predication;14using NBi.Core.Analysis.Member.Builders.Comparer.Strategy.Predication.Numeric;15using NBi.Core.Analysis.Member.Builders.Comparer.Strategy.Predication.DateTime;16using NBi.Core.Analysis.Member.Builders.Comparer.Strategy.Predication.Text;17using NBi.Core.Analysis.Member.Builders.Comparer.Strategy.Predication.Numeric.NumericPredicate;18using NBi.Core.Analysis.Member.Builders.Comparer.Strategy.Predication.DateTime.DateTimePredicate;19using NBi.Core.Analysis.Member.Builders.Comparer.Strategy.Predication.Text.TextPredicate;20using NBi.Core.Calculation;21using NBi.Core.Calculation.Predicate;22using NBi.Core.Calculation.Predicate.Numeric;23using NBi.Core.Calculation.Predicate.Text;24using NBi.Core.Calculation.Predicate.DateTime;25{26 {27 static void Main(string[] args)28 {29 var command = new MembersCommand();30 command.Request = new MetadataRequest();31 command.Request.Dimensions.Add(new DimensionRequest("Time"));32 command.Request.Dimensions.Add(new DimensionRequest("Customer"));33 command.Request.Dimensions.Add(new DimensionRequest("Product"));34 command.Request.Metrics.Add(new MetricRequest("Sales"));35 command.Request.Metrics.Add(new MetricRequest("Quantity"));36 command.Request.Metrics.Add(new MetricRequest("Discount"));37 command.Request.Filters.Add(new FilterRequest("Time", "1997"));38 command.Request.Filters.Add(new FilterRequest("Customer", "France"));39 command.Request.Filters.Add(new FilterRequest("Product", "Bike"));40 var builder = new MembersCommandBuilder();41 var members = builder.Build(command);42 foreach (var member in members)43 {44 var sb = new StringBuilder();45 foreach (var cell in member.Cells)46 {47 sb.AppendFormat("{0} = {1} ", cell.Key, cell.Value);48 }
Build
Using AI Code Generation
1using NBi.Core.Analysis.Member;2using NBi.Core.Analysis.Request;3using NBi.Core.Analysis.Metadata;4using NBi.Core.Analysis.Member.Builders;5using NBi.Core.Analysis.Member.Resolver;6using NBi.Core.Analysis.Member.Rewriter;7using NBi.Core.Analysis.Member;8using NBi.Core.Analysis.Request;9using NBi.Core.Analysis.Metadata;10using NBi.Core.Analysis.Member.Builders;11using NBi.Core.Analysis.Member.Resolver;12using NBi.Core.Analysis.Member.Rewriter;13using NBi.Core.Analysis.Member;14using NBi.Core.Analysis.Request;15using NBi.Core.Analysis.Metadata;16using NBi.Core.Analysis.Member.Builders;17using NBi.Core.Analysis.Member.Resolver;18using NBi.Core.Analysis.Member.Rewriter;19using NBi.Core.Analysis.Member;20using NBi.Core.Analysis.Request;21using NBi.Core.Analysis.Metadata;22using NBi.Core.Analysis.Member.Builders;23using NBi.Core.Analysis.Member.Resolver;24using NBi.Core.Analysis.Member.Rewriter;25using NBi.Core.Analysis.Member;26using NBi.Core.Analysis.Request;27using NBi.Core.Analysis.Metadata;28using NBi.Core.Analysis.Member.Builders;29using NBi.Core.Analysis.Member.Resolver;30using NBi.Core.Analysis.Member.Rewriter;31using NBi.Core.Analysis.Member;32using NBi.Core.Analysis.Request;33using NBi.Core.Analysis.Metadata;34using NBi.Core.Analysis.Member.Builders;35using NBi.Core.Analysis.Member.Resolver;36using NBi.Core.Analysis.Member.Rewriter;37using NBi.Core.Analysis.Member;38using NBi.Core.Analysis.Request;39using NBi.Core.Analysis.Metadata;40using NBi.Core.Analysis.Member.Builders;41using NBi.Core.Analysis.Member.Resolver;42using NBi.Core.Analysis.Member.Rewriter;43using NBi.Core.Analysis.Member;44using NBi.Core.Analysis.Request;45using NBi.Core.Analysis.Metadata;46using NBi.Core.Analysis.Member.Builders;47using NBi.Core.Analysis.Member.Resolver;48using NBi.Core.Analysis.Member.Rewriter;49using NBi.Core.Analysis.Member;50using NBi.Core.Analysis.Request;51using NBi.Core.Analysis.Metadata;52using NBi.Core.Analysis.Member.Builders;53using NBi.Core.Analysis.Member.Resolver;54using NBi.Core.Analysis.Member.Rewriter;55using NBi.Core.Analysis.Member;
Build
Using AI Code Generation
1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6using NBi.Core.Analysis.Member;7using NBi.Core.Analysis.Request;8using NBi.Core.Analysis.Metadata;9using NBi.Core.Calculation;10using NBi.Core.Calculation.Predicate;11using NBi.Core.Calculation.Ranking;12using NBi.Core.Calculation.Ranking.Comparer;13using NBi.Core.Calculation.Ranking.Equivalence;14using NBi.Core.ResultSet;15using NBi.Core.ResultSet.Alteration.Duplication;16using NBi.Core.ResultSet.Alteration.Renaming;17using NBi.Core.ResultSet.Alteration.Renaming.Strategy;18using NBi.Core.ResultSet.Alteration.Renaming.Strategy.Column;19using NBi.Core.ResultSet.Alteration.Renaming.Strategy.Row;20using NBi.Core.ResultSet.Alteration.Duplication.Strategy;21using NBi.Core.ResultSet.Resolver;22using NBi.Core.ResultSet.Resolver.File;23using NBi.Core.ResultSet.Resolver.File.Csv;24using NBi.Core.ResultSet.Resolver.File.Excel;25using NBi.Core.ResultSet.Resolver.File.Json;26using NBi.Core.ResultSet.Resolver.File.Xml;27using NBi.Core.ResultSet.Resolver.File.JsonPath;28using NBi.Core.ResultSet.Resolver.File.JsonPath.Impl;29using NBi.Core.ResultSet.Resolver.File.JsonPath.Impl.Rfc6901;30using NBi.Core.ResultSet.Resolver.File.JsonPath.Impl.JmesPath;31using NBi.Core.ResultSet.Resolver.File.JsonPath.Impl.LINQ;32using NBi.Core.ResultSet.Resolver.File.JsonPath.Impl.JPath;33using NBi.Core.ResultSet.Resolver.File.JsonPath.Impl.Newtonsoft;34using NBi.Core.ResultSet.Resolver.File.JsonPath.Impl.Newtonsoft.Rfc6901;35using NBi.Core.ResultSet.Resolver.File.JsonPath.Impl.Newtonsoft.JmesPath;36using NBi.Core.ResultSet.Resolver.File.JsonPath.Impl.Newtonsoft.LINQ;37using NBi.Core.ResultSet.Resolver.File.JsonPath.Impl.Newtonsoft.JPath;38using NBi.Core.ResultSet.Resolver.File.JsonPath.Impl.Newtonsoft.Impl;
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!!