Best NBi code snippet using NBi.Core.ResultSet.ColumnOrdinalIdentifier.ColumnOrdinalIdentifier
LookupReplaceEngineTest.cs
Source:LookupReplaceEngineTest.cs
...38 )).Execute, null);39 var engine = new LookupReplaceEngine(40 new LookupReplaceArgs( 41 reference, 42 new ColumnMapping(new ColumnOrdinalIdentifier(1), new ColumnOrdinalIdentifier(0), ColumnType.Text),43 new ColumnOrdinalIdentifier(1)44 ));45 var result = engine.Execute(candidate);46 Assert.That(result.Columns.Count, Is.EqualTo(3));47 Assert.That(result.Rows.Count, Is.EqualTo(4));48 Assert.That(result.Rows.Cast<DataRow>().Select(x => x[1]).Distinct(), Does.Contain("alpha"));49 Assert.That(result.Rows.Cast<DataRow>().Select(x => x[1]).Distinct(), Does.Contain("beta"));50 Assert.That(result.Rows.Cast<DataRow>().Select(x => x[1] as string).Where(x => x != "alpha" && x != "beta"), Is.Empty); 51 }52 [Test]53 public void Execute_AllLookupFoundSwitchingFromTextToNumeric_CorrectReplacement()54 {55 var candidate = new ObjectsResultSetResolver(56 new ObjectsResultSetResolverArgs(57 new[] {58 new object[] { 1, "A", 100 },59 new object[] { 2, "B", 101 },60 new object[] { 3, "A", 125 },61 new object[] { 4, "B", 155 }62 }63 )).Execute();64 var reference = new ResultSetService(65 new ObjectsResultSetResolver(66 new ObjectsResultSetResolverArgs(67 new[] {68 new object[] { "A", 10.2 },69 new object[] { "B", 21.1 },70 }71 )).Execute, null);72 var engine = new LookupReplaceEngine(73 new LookupReplaceArgs(74 reference,75 new ColumnMapping(new ColumnOrdinalIdentifier(1), new ColumnOrdinalIdentifier(0), ColumnType.Text),76 new ColumnOrdinalIdentifier(1)77 ));78 var result = engine.Execute(candidate);79 Assert.That(result.Columns.Count, Is.EqualTo(3));80 Assert.That(result.Rows.Count, Is.EqualTo(4));81 Assert.That(result.Rows.Cast<DataRow>().Select(x => x[1]).Distinct(), Does.Contain(10.2));82 Assert.That(result.Rows.Cast<DataRow>().Select(x => x[1]).Distinct(), Does.Contain(21.1));83 Assert.That(result.Rows.Cast<DataRow>().Select(x => Convert.ToDecimal(x[1])).Where(x => x != 10.2m && x != 21.1m), Is.Empty);84 }85 [Test]86 public void ExecuteWithFailureStretegy_OneLookupMissing_ExceptionThrown()87 {88 var candidate = new ObjectsResultSetResolver(89 new ObjectsResultSetResolverArgs(90 new[] {91 new object[] { 1, "A", 100 },92 new object[] { 2, "B", 101 },93 new object[] { 3, "A", 125 },94 new object[] { 4, "C", 155 }95 }96 )).Execute();97 var reference = new ResultSetService(98 new ObjectsResultSetResolver(99 new ObjectsResultSetResolverArgs(100 new[] {101 new object[] { "A", "alpha" },102 new object[] { "B", "beta" },103 }104 )).Execute, null);105 var engine = new LookupReplaceEngine(106 new LookupReplaceArgs(107 reference,108 new ColumnMapping(new ColumnOrdinalIdentifier(1), new ColumnOrdinalIdentifier(0), ColumnType.Text),109 new ColumnOrdinalIdentifier(1),110 new FailureMissingStrategy()111 ));112 var ex = Assert.Throws<NBiException>(() => engine.Execute(candidate));113 Assert.That(ex.Message, Does.Contain("'C'"));114 }115 [Test]116 public void ExecuteWithDefaultValueStrategy_OneLookupMissing_DefaultValueApplied()117 {118 var candidate = new ObjectsResultSetResolver(119 new ObjectsResultSetResolverArgs(120 new[] {121 new object[] { 1, "A", 100 },122 new object[] { 2, "B", 101 },123 new object[] { 3, "A", 125 },124 new object[] { 4, "C", 155 }125 }126 )).Execute();127 var reference = new ResultSetService(128 new ObjectsResultSetResolver(129 new ObjectsResultSetResolverArgs(130 new[] {131 new object[] { "A", "alpha" },132 new object[] { "B", "beta" },133 }134 )).Execute, null);135 var engine = new LookupReplaceEngine(136 new LookupReplaceArgs(137 reference,138 new ColumnMapping(new ColumnOrdinalIdentifier(1), new ColumnOrdinalIdentifier(0), ColumnType.Text),139 new ColumnOrdinalIdentifier(1),140 new DefaultValueMissingStrategy("omega")141 ));142 var result = engine.Execute(candidate);143 Assert.That(result.Rows.Count, Is.EqualTo(4));144 Assert.That(result.Rows.Cast<DataRow>().Select(x => x[1]).Distinct(), Does.Contain("alpha"));145 Assert.That(result.Rows.Cast<DataRow>().Select(x => x[1]).Distinct(), Does.Contain("beta"));146 var otherValues = result.Rows.Cast<DataRow>().Select(x => x[1] as string).Where(x => x != "alpha" && x != "beta");147 Assert.That(otherValues, Is.Not.Empty);148 Assert.That(otherValues, Does.Contain("omega"));149 }150 [Test]151 public void ExecuteWithOriginalValueStrategy_OneLookupMissing_OriginalValueApplied()152 {153 var candidate = new ObjectsResultSetResolver(154 new ObjectsResultSetResolverArgs(155 new[] {156 new object[] { 1, "A", 100 },157 new object[] { 2, "B", 101 },158 new object[] { 3, "A", 125 },159 new object[] { 4, "C", 155 }160 }161 )).Execute();162 var reference = new ResultSetService(163 new ObjectsResultSetResolver(164 new ObjectsResultSetResolverArgs(165 new[] {166 new object[] { "A", "alpha" },167 new object[] { "B", "beta" },168 }169 )).Execute, null);170 var engine = new LookupReplaceEngine(171 new LookupReplaceArgs(172 reference,173 new ColumnMapping(new ColumnOrdinalIdentifier(1), new ColumnOrdinalIdentifier(0), ColumnType.Text),174 new ColumnOrdinalIdentifier(1),175 new OriginalValueMissingStrategy()176 ));177 var result = engine.Execute(candidate);178 Assert.That(result.Rows.Count, Is.EqualTo(4));179 Assert.That(result.Rows.Cast<DataRow>().Select(x => x[1]).Distinct(), Does.Contain("alpha"));180 Assert.That(result.Rows.Cast<DataRow>().Select(x => x[1]).Distinct(), Does.Contain("beta"));181 var otherValues = result.Rows.Cast<DataRow>().Select(x => x[1] as string).Where(x => x != "alpha" && x != "beta");182 Assert.That(otherValues, Is.Not.Empty);183 Assert.That(otherValues, Does.Contain("C"));184 }185 [Test]186 public void ExecuteWithDiscardRowStrategy_OneLookupMissing_LessRowsReturned()187 {188 var candidate = new ObjectsResultSetResolver(189 new ObjectsResultSetResolverArgs(190 new[] {191 new object[] { 1, "A", 100 },192 new object[] { 2, "B", 101 },193 new object[] { 3, "A", 125 },194 new object[] { 4, "C", 155 }195 }196 )).Execute();197 var reference = new ResultSetService(198 new ObjectsResultSetResolver(199 new ObjectsResultSetResolverArgs(200 new[] {201 new object[] { "A", "alpha" },202 new object[] { "B", "beta" },203 }204 )).Execute, null);205 var engine = new LookupReplaceEngine(206 new LookupReplaceArgs(207 reference,208 new ColumnMapping(new ColumnOrdinalIdentifier(1), new ColumnOrdinalIdentifier(0), ColumnType.Text),209 new ColumnOrdinalIdentifier(1),210 new DiscardRowMissingStrategy()211 ));212 var result = engine.Execute(candidate);213 Assert.That(result.Rows.Count, Is.EqualTo(3));214 Assert.That(result.Rows.Cast<DataRow>().Select(x => x[1]).Distinct(), Does.Contain("alpha"));215 Assert.That(result.Rows.Cast<DataRow>().Select(x => x[1]).Distinct(), Does.Contain("beta"));216 var otherValues = result.Rows.Cast<DataRow>().Select(x => x[1] as string).Where(x => x != "alpha" && x != "beta");217 Assert.That(otherValues, Is.Empty);218 }219 }220}...
TransformationProviderTest.cs
Source:TransformationProviderTest.cs
...28 && t.OriginalType == ColumnType.Text29 && t.Code == "value.Substring(0,1)"30 );31 var provider = new TransformationProvider(new ServiceLocator(), Context.None);32 provider.Add(new ColumnOrdinalIdentifier(0), transformation);33 provider.Transform(resultSet);34 Assert.That(resultSet.Columns[0].ColumnName, Is.EqualTo("MyCol0"));35 Assert.That(resultSet.Columns[1].ColumnName, Is.EqualTo("MyCol1"));36 Assert.That(resultSet.Columns.Count, Is.EqualTo(2));37 }38 [Test]39 public void Transform_SimpleTranformation_Correct()40 {41 var resultSet = new NBi.Core.ResultSet.ResultSet();42 resultSet.Load("aaaa;10");43 var transformation = Mock.Of<ITransformationInfo>44 (45 t => t.Language == LanguageType.CSharp46 && t.OriginalType == ColumnType.Text47 && t.Code == "value.Substring(0,1)"48 );49 var provider = new TransformationProvider(new ServiceLocator(), Context.None);50 provider.Add(new ColumnOrdinalIdentifier(0), transformation);51 provider.Transform(resultSet);52 Assert.That(resultSet.Rows[0][0], Is.EqualTo("a"));53 }54 [Test]55 public void Transform_NativeTranformationTrim_Correct()56 {57 var resultSet = new NBi.Core.ResultSet.ResultSet();58 resultSet.Load(" aaaa ;10");59 var transformation = Mock.Of<ITransformationInfo>60 (61 t => t.Language == LanguageType.Native62 && t.OriginalType == ColumnType.Text63 && t.Code == "text-to-trim"64 );65 var provider = new TransformationProvider(new ServiceLocator(), Context.None);66 provider.Add(new ColumnOrdinalIdentifier(0), transformation);67 provider.Transform(resultSet);68 Assert.That(resultSet.Rows[0][0], Is.EqualTo("aaaa"));69 }70 [Test]71 public void Transform_NativeTranformationFirstCharWithContext_Correct()72 {73 var resultSet = new NBi.Core.ResultSet.ResultSet();74 resultSet.Load(new[] { new object[] { "123456789", 6 }, new object[] { "abcdefgh", 2 } });75 var transformation = Mock.Of<ITransformationInfo>76 (77 t => t.Language == LanguageType.Native78 && t.OriginalType == ColumnType.Text79 && t.Code == "text-to-first-chars(#1)"80 );81 var provider = new TransformationProvider(new ServiceLocator(), Context.None);82 provider.Add(new ColumnOrdinalIdentifier(0), transformation);83 provider.Transform(resultSet);84 Assert.That(resultSet.Rows[0][0], Is.EqualTo("123456"));85 Assert.That(resultSet.Rows[1][0], Is.EqualTo("ab"));86 }87 [Test]88 public void Transform_NativeTranformationBlankToNull_Correct()89 {90 var resultSet = new NBi.Core.ResultSet.ResultSet();91 resultSet.Load("\t;10");92 var transformation = Mock.Of<ITransformationInfo>93 (94 t => t.Language == LanguageType.Native95 && t.OriginalType == ColumnType.Text96 && t.Code == "blank-to-null"97 );98 var provider = new TransformationProvider(new ServiceLocator(), Context.None);99 provider.Add(new ColumnOrdinalIdentifier(0), transformation);100 provider.Transform(resultSet);101 Assert.That(resultSet.Rows[0][0], Is.EqualTo("(null)"));102 }103 [Test]104 public void Transform_NativeTranformationUnknown_Exception()105 {106 var resultSet = new NBi.Core.ResultSet.ResultSet();107 resultSet.Load("\t;10");108 var transformation = Mock.Of<ITransformationInfo>109 (110 t => t.Language == LanguageType.Native111 && t.OriginalType == ColumnType.Text112 && t.Code == "unknown"113 );114 var provider = new TransformationProvider(new ServiceLocator(), null);115 Assert.Throws<NotImplementedTransformationException>(() => provider.Add(new ColumnOrdinalIdentifier(0), transformation));116 }117 [Test]118 public void Transform_TypeSwitch_Correct()119 {120 var resultSet = new NBi.Core.ResultSet.ResultSet();121 var obj = new object[] { new DateTime(2016,10,1) };122 resultSet.Load(Enumerable.Repeat(obj,1));123 var transformation = Mock.Of<ITransformationInfo>124 (125 t => t.Language == LanguageType.CSharp126 && t.OriginalType == ColumnType.DateTime127 && t.Code == "value.Month + (value.Year-2000)*12"128 );129 var provider = new TransformationProvider(new ServiceLocator(), Context.None);130 provider.Add(new ColumnOrdinalIdentifier(0), transformation);131 provider.Transform(resultSet);132 Assert.That(resultSet.Rows[0][0], Is.EqualTo(202));133 }134 }135}...
ColumnMappingCollectionTest.cs
Source:ColumnMappingCollectionTest.cs
...18 var mappings = new ColumnMappingCollection19 {20 new ColumnMapping(new ColumnNameIdentifier("name"), ColumnType.Text)21 };22 Assert.Throws<NBiException>(() => mappings.Add(new ColumnMapping(new ColumnOrdinalIdentifier(1), ColumnType.Text)));23 }24 [Test]25 public void Add_MixOfNameAndOrdinalInOneMapping_NoException()26 {27 var mappings = new ColumnMappingCollection();28 Assert.DoesNotThrow(() => mappings.Add(new ColumnMapping(new ColumnNameIdentifier("name"), new ColumnOrdinalIdentifier(1), ColumnType.Text)));29 }30 [Test]31 public void Add_MixOfNameAndOrdinalInSecondMapping_NoException()32 {33 var mappings = new ColumnMappingCollection()34 {35 new ColumnMapping(new ColumnNameIdentifier("zero"), new ColumnOrdinalIdentifier(0), ColumnType.Text)36 };37 Assert.DoesNotThrow(() => mappings.Add(new ColumnMapping(new ColumnNameIdentifier("name"), new ColumnOrdinalIdentifier(1), ColumnType.Text)));38 }39 }40}...
ColumnOrdinalIdentifier
Using AI Code Generation
1using NBi.Core.ResultSet;2using System;3using System.Collections.Generic;4using System.Linq;5using System.Text;6using System.Threading.Tasks;7{8 {9 static void Main(string[] args)10 {11 ColumnOrdinalIdentifier identifier = new ColumnOrdinalIdentifier();12 identifier.Test();13 }14 public void Test()15 {16 var identifier = new NBi.Core.ResultSet.ColumnOrdinalIdentifier(1);17 Console.WriteLine(identifier.Execute(new object[] { "a", "b", "c" }));18 Console.WriteLine(identifier.Execute(new object[] { "a", "b", "c" }));19 Console.WriteLine(identifier.Execute(new object[] { "a", "b", "c" }));20 }21 }22}
ColumnOrdinalIdentifier
Using AI Code Generation
1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6using NBi.Core.ResultSet;7{8 {9 public void ColumnOrdinalIdentifier()10 {11 ColumnOrdinalIdentifier columnIdentifier = new ColumnOrdinalIdentifier(0);12 }13 }14}
ColumnOrdinalIdentifier
Using AI Code Generation
1var columnOrdinalIdentifier = new NBi.Core.ResultSet.ColumnOrdinalIdentifier(0);2var columnNameIdentifier = new NBi.Core.ResultSet.ColumnNameIdentifier("Column1");3var resultSetTable = new NBi.Core.ResultSet.ResultSetTable();4var resultSetTable = new NBi.Core.ResultSet.ResultSetTable("TestTable");5var resultSetTable = new NBi.Core.ResultSet.ResultSetTable("TestTable", "TestTable");6var resultSetTable = new NBi.Core.ResultSet.ResultSetTable("TestTable", "TestTable", "TestTable");7var resultSetTable = new NBi.Core.ResultSet.ResultSetTable("TestTable", "TestTable", "TestTable", "TestTable");8var resultSetTable = new NBi.Core.ResultSet.ResultSetTable("TestTable", "TestTable", "TestTable", "TestTable", "TestTable");9var resultSetTable = new NBi.Core.ResultSet.ResultSetTable("TestTable", "TestTable", "TestTable", "TestTable", "TestTable", "TestTable");10var resultSetTable = new NBi.Core.ResultSet.ResultSetTable("TestTable", "TestTable", "TestTable", "TestTable", "TestTable", "TestTable", "TestTable");11var resultSetTable = new NBi.Core.ResultSet.ResultSetTable("TestTable", "TestTable", "TestTable", "TestTable", "TestTable", "TestTable", "TestTable", "TestTable");
ColumnOrdinalIdentifier
Using AI Code Generation
1using NBi.Core.ResultSet;2using System;3using System.Collections.Generic;4using System.Data;5using System.Linq;6using System.Text;7using System.Threading.Tasks;8{9 {10 public void ColumnOrdinalIdentifierMethod()11 {12 DataTable table = new DataTable();13 table.Columns.Add("col1");14 table.Columns.Add("col2");15 table.Columns.Add("col3");16 var identifier = new NBi.Core.ResultSet.ColumnOrdinalIdentifier(1);17 identifier.InferCaption(table);18 identifier.InferIndex(table);19 }20 }21}22using NBi.Core.ResultSet;23using System;24using System.Collections.Generic;25using System.Data;26using System.Linq;27using System.Text;28using System.Threading.Tasks;29{30 {31 public void ColumnPositionIdentifierMethod()32 {33 DataTable table = new DataTable();34 table.Columns.Add("col1");35 table.Columns.Add("col2");36 table.Columns.Add("col3");37 var identifier = new NBi.Core.ResultSet.ColumnPositionIdentifier("col2");38 identifier.InferCaption(table);39 identifier.InferIndex(table);40 }41 }42}43using NBi.Core.ResultSet;44using System;45using System.Collections.Generic;46using System.Data;47using System.Linq;48using System.Text;49using System.Threading.Tasks;50{51 {52 public void ColumnCaptionIdentifierMethod()53 {54 DataTable table = new DataTable();55 table.Columns.Add("col1");56 table.Columns.Add("col2");57 table.Columns.Add("col3");58 var identifier = new NBi.Core.ResultSet.ColumnCaptionIdentifier(2);59 identifier.InferCaption(table);60 identifier.InferIndex(table);61 }62 }63}64using NBi.Core.ResultSet;65using System;66using System.Collections.Generic;67using System.Data;68using System.Linq;69using System.Text;70using System.Threading.Tasks;71{72 {
ColumnOrdinalIdentifier
Using AI Code Generation
1using NBi.Core.ResultSet;2using System;3using System.Collections.Generic;4using System.Linq;5using System.Text;6using System.Threading.Tasks;7{8 {9 static void Main(string[] args)10 {11 ColumnOrdinalIdentifier columnOrdinalIdentifier = new ColumnOrdinalIdentifier();12 columnOrdinalIdentifier.Position = 1;13 Console.WriteLine(columnOrdinalIdentifier.GetPosition());14 Console.ReadLine();15 }16 }17}
ColumnOrdinalIdentifier
Using AI Code Generation
1{2 public ColumnOrdinalIdentifier(int index)3 {4 Index = index;5 }6 public int Index { get; private set; }7 public override string ToString()8 {9 return string.Format("Column ordinal {0}", Index);10 }11}12{13 public ColumnNameIdentifier(string name)14 {15 Name = name;16 }17 public string Name { get; private set; }18 public override string ToString()19 {20 return string.Format("Column name {0}", Name);21 }22}23{24 public ColumnPositionIdentifier(int index)25 {26 Index = index;27 }28 public int Index { get; private set; }29 public override string ToString()30 {31 return string.Format("Column position {0}", Index);32 }33}34{35 public ColumnTypeIdentifier(Type type)36 {37 Type = type;38 }39 public Type Type { get; private set; }40 public override string ToString()41 {42 return string.Format("Column type {0}", Type);43 }44}45{46 public ColumnTypeIdentifier(Type type)47 {48 Type = type;49 }50 public Type Type { get; private set; }51 public override string ToString()52 {53 return string.Format("Column type {0}", Type);54 }55}56{57 public ColumnTypeIdentifier(Type type)58 {59 Type = type;60 }61 public Type Type { get; private set; }62 public override string ToString()63 {64 return string.Format("Column type {0}", Type);65 }66}
ColumnOrdinalIdentifier
Using AI Code Generation
1using NBi.Core.ResultSet;2ColumnOrdinalIdentifier columnOrdinalIdentifier = new ColumnOrdinalIdentifier();3columnOrdinalIdentifier.Initialize("1");4int columnIndex = columnOrdinalIdentifier.Execute();5using NBi.Core.ResultSet;6ColumnNameIdentifier columnNameIdentifier = new ColumnNameIdentifier();7columnNameIdentifier.Initialize("Column1");8int columnIndex = columnNameIdentifier.Execute();9using NBi.Core.ResultSet;10ColumnPositionIdentifier columnPositionIdentifier = new ColumnPositionIdentifier();11columnPositionIdentifier.Initialize("1");12int columnIndex = columnPositionIdentifier.Execute();13using NBi.Core.ResultSet;14ColumnPositionIdentifier columnPositionIdentifier = new ColumnPositionIdentifier();15columnPositionIdentifier.Initialize("first");16int columnIndex = columnPositionIdentifier.Execute();17using NBi.Core.ResultSet;18ColumnPositionIdentifier columnPositionIdentifier = new ColumnPositionIdentifier();19columnPositionIdentifier.Initialize("last");20int columnIndex = columnPositionIdentifier.Execute();21using NBi.Core.ResultSet;22ColumnPositionIdentifier columnPositionIdentifier = new ColumnPositionIdentifier();23columnPositionIdentifier.Initialize("last-1");24int columnIndex = columnPositionIdentifier.Execute();25using NBi.Core.ResultSet;26ColumnPositionIdentifier columnPositionIdentifier = new ColumnPositionIdentifier();27columnPositionIdentifier.Initialize("last-2");28int columnIndex = columnPositionIdentifier.Execute();29using NBi.Core.ResultSet;30ColumnPositionIdentifier columnPositionIdentifier = new ColumnPositionIdentifier();31columnPositionIdentifier.Initialize("last-3");32int columnIndex = columnPositionIdentifier.Execute();33using NBi.Core.ResultSet;34ColumnPositionIdentifier columnPositionIdentifier = new ColumnPositionIdentifier();35columnPositionIdentifier.Initialize("last-4");
ColumnOrdinalIdentifier
Using AI Code Generation
1using System;2using NBi.Core.ResultSet;3{4 public static void Main()5 {6 ColumnOrdinalIdentifier identifier = new ColumnOrdinalIdentifier(1);7 Console.WriteLine(identifier.Execute(new ResultSet.ResultSet(new string[] { "col1", "col2" }, new string[][] { new string[] { "a", "b" } })));8 }9}10using System;11using NBi.Core.ResultSet;12{13 public static void Main()14 {15 ColumnOrdinalIdentifier identifier = new ColumnOrdinalIdentifier(1);16 Console.WriteLine(identifier.Execute(new ResultSet.ResultSet(new string[] { "col1", "col2" }, new string[][] { new string[] { "a", "b" } })));17 }18}19using System;20using NBi.Core.ResultSet;21{22 public static void Main()23 {24 ColumnOrdinalIdentifier identifier = new ColumnOrdinalIdentifier(1);25 Console.WriteLine(identifier.Execute(new ResultSet.ResultSet(new string[] { "col1", "col2" }, new string[][] { new string[] { "a", "b" } })));26 }27}28using System;29using NBi.Core.ResultSet;30{31 public static void Main()32 {33 ColumnOrdinalIdentifier identifier = new ColumnOrdinalIdentifier(1);34 Console.WriteLine(identifier.Execute(new ResultSet.ResultSet(new string[] { "col1", "col2" }, new string[][] { new string[] { "a", "b" } })));35 }36}37using System;38using NBi.Core.ResultSet;39{40 public static void Main()41 {42 ColumnOrdinalIdentifier identifier = new ColumnOrdinalIdentifier(1);43 Console.WriteLine(identifier.Execute(new ResultSet.ResultSet(new string[] {
ColumnOrdinalIdentifier
Using AI Code Generation
1using NBi.Core.ResultSet;2using System;3using System.Data;4{5 {6 static void Main(string[] args)7 {8 DataTable dt = new DataTable();9 dt.Columns.Add("ID", typeof(int));10 dt.Columns.Add("Name", typeof(string));11 dt.Columns.Add("Age", typeof(int));12 dt.Rows.Add(1, "John", 21);13 dt.Rows.Add(2, "Mary", 22);14 dt.Rows.Add(3, "Peter", 23);15 int ordinal = ColumnOrdinalIdentifier.GetOrdinal(dt, "Name");16 Console.WriteLine("Ordinal of column with name 'Name' is {0}", ordinal);17 Console.Read();18 }19 }20}
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!!