Best NBi code snippet using NBi.Core.Query.Execution.OleDbExecutionEngine
OleDbExecutionEngineTest.cs
Source:OleDbExecutionEngineTest.cs
...6using NBi.Core;7namespace NBi.Testing.Integration.Core.Query.Execution8{9 [TestFixture]10 public class OleDbExecutionEngineTest11 {12 [Test]13 public void Execute_WaitFor3SecondsTimeoutSetTo1_Timeout()14 {15 var query = "WAITFOR DELAY '00:00:03';";16 var cmd = new OleDbCommand(query, new OleDbConnection(ConnectionStringReader.GetOleDbSql()))17 {18 CommandTimeout = 119 };20 var qe = new OleDbExecutionEngine(cmd.Connection, cmd);21 Assert.Throws<CommandTimeoutException>(delegate { qe.Execute(); });22 }23 [Test]24 public void Execute_WaitFor3SecondsTimeoutSetTo0_NoTimeOut()25 {26 var query = "WAITFOR DELAY '00:00:03';";27 var cmd = new OleDbCommand(query, new OleDbConnection(ConnectionStringReader.GetOleDbSql()))28 {29 CommandTimeout = 030 };31 var qe = new OleDbExecutionEngine(cmd.Connection, cmd);32 Assert.DoesNotThrow(delegate { qe.Execute(); });33 }34 [Test]35 public void Execute_ValidQuery_DataSetFilled()36 {37 var query = "select * from [Sales].[Currency];";38 var cmd = new OleDbCommand(query, new OleDbConnection(ConnectionStringReader.GetOleDbSql())) { CommandTimeout = 0 };39 var qe = new OleDbExecutionEngine(cmd.Connection, cmd);40 var ds = qe.Execute();41 Assert.That(ds.Tables, Has.Count.EqualTo(1));42 Assert.That(ds.Tables[0].Columns, Has.Count.EqualTo(3));43 Assert.That(ds.Tables[0].Rows, Has.Count.EqualTo(105));44 }45 [Test]46 public void ExecuteScalar_ValidQuery_DataSetFilled()47 {48 var query = "select top(1) CurrencyCode from [Sales].[Currency] where Name like '%Canad%'";49 var cmd = new OleDbCommand(query, new OleDbConnection(ConnectionStringReader.GetOleDbSql())) { CommandTimeout = 0 };50 var qe = new OleDbExecutionEngine(cmd.Connection, cmd);51 var value = qe.ExecuteScalar();52 Assert.That(value, Is.EqualTo("CAD"));53 }54 [Test]55 public void ExecuteList_ValidQuery_DataSetFilled()56 {57 var query = "select top(10) CurrencyCode from [Sales].[Currency] where CurrencyCode like '%D' order by 1 asc";58 var cmd = new OleDbCommand(query, new OleDbConnection(ConnectionStringReader.GetOleDbSql())) { CommandTimeout = 0 };59 var qe = new OleDbExecutionEngine(cmd.Connection, cmd);60 var values = qe.ExecuteList<string>();61 Assert.That(values, Has.Count.EqualTo(10));62 Assert.That(values, Has.Member("CAD"));63 }64 }65}...
OledbExecutionEngine.cs
Source:OledbExecutionEngine.cs
...10 /// Engine wrapping the System.Data.OleDb namespace for execution of NBi tests11 /// <remarks>Instances of this class are built by the means of the <see>QueryEngineFactory</see></remarks>12 /// </summary>13 [SupportedCommandType(typeof(OleDbCommand))]14 internal class OleDbExecutionEngine : DbCommandExecutionEngine15 {16 public OleDbExecutionEngine(OleDbConnection connection, OleDbCommand command)17 : base(connection, command)18 { }19 20 internal override void OpenConnection(IDbConnection connection)21 {22 var connectionString = Command.Connection.ConnectionString;23 try24 { connection.ConnectionString = connectionString; }25 catch (ArgumentException ex)26 { throw new ConnectionException(ex, connectionString); }27 try28 { connection.Open(); }29 catch (OleDbException ex)30 { throw new ConnectionException(ex, connectionString); }...
ExecutionEngineFactory.cs
Source:ExecutionEngineFactory.cs
...15 private Type[] classics = new[] 16 {17 typeof(AdomdExecutionEngine),18 typeof(OdbcExecutionEngine),19 typeof(OleDbExecutionEngine),20 typeof(SqlExecutionEngine)21 };22 public ExecutionEngineFactory() 23 : base()24 {25 RegisterEngines(classics);26 }27 public ExecutionEngineFactory(ClientProvider clientProvider, CommandProvider commandProvider)28 : base(clientProvider, commandProvider)29 {30 RegisterEngines(classics);31 }32 public ExecutionEngineFactory(ClientProvider clientProvider, CommandProvider commandProvider, IExtensionsConfiguration config)33 : base(clientProvider, commandProvider)...
OleDbExecutionEngine
Using AI Code Generation
1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6using NBi.Core.Query.Execution;7{8 {9 static void Main(string[] args)10 {11 var connectionString = "Provider=SQLNCLI11;Data Source=.;Integrated Security=SSPI;Initial Catalog=AdventureWorks2012";12 var query = "select top 10 * from Sales.SalesOrderHeader";13 var engine = new OleDbExecutionEngine(connectionString);14 var result = engine.Execute(query);15 foreach (var row in result)16 Console.WriteLine(string.Join(" | ", row.Select(x => x.ToString())));17 }18 }19}20using System;21using System.Collections.Generic;22using System.Linq;23using System.Text;24using System.Threading.Tasks;25using NBi.Core.Query.Execution;26using NBi.Core.Query.Resolver;27using NBi.Core.Query.Resolver.Command;28using NBi.Core.Query.Resolver.Csv;29using NBi.Core.Query.Resolver.Variables;30{31 {32 static void Main(string[] args)33 {34 var connectionString = "Provider=SQLNCLI11;Data Source=.;Integrated Security=SSPI;Initial Catalog=AdventureWorks2012";35 var query = "select top 10 * from Sales.SalesOrderHeader";36 var engine = new OleDbExecutionEngine(connectionString);37 var command = new TextCommand(query);38 var variables = new List<IVariable>();39 var csv = new CsvProfile();40 var resolver = new CommandResolver(command, variables, csv);41 var result = engine.Execute(resolver);42 foreach (var row in result)43 Console.WriteLine(string.Join(" | ", row.Select(x => x.ToString())));44 }45 }46}47using System;48using System.Collections.Generic;49using System.Linq;50using System.Text;51using System.Threading.Tasks;
OleDbExecutionEngine
Using AI Code Generation
1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6using NBi.Core.Query.Execution;7using System.Data.OleDb;8using System.Data;9{10 {11 static void Main(string[] args)12 {13 string connString = "Provider=SQLNCLI11;Data Source=.;Integrated Security=SSPI;Initial Catalog=AdventureWorks2012";14 string query = "select * from DimCustomer";15 OleDbConnection conn = new OleDbConnection(connString);16 OleDbCommand command = new OleDbCommand(query, conn);17 OleDbExecutionEngine engine = new OleDbExecutionEngine();18 var result = engine.Execute(command);19 Console.WriteLine("Result: " + result);20 Console.ReadLine();21 }22 }23}
OleDbExecutionEngine
Using AI Code Generation
1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6using NBi.Core.Query.Execution;7using System.Data;8using System.Data.OleDb;9{10 {11 public OleDbExecutionEngine(string connectionString)12 : base(connectionString, new OleDbCommandFactory())13 { }14 }15}16using System;17using System.Collections.Generic;18using System.Linq;19using System.Text;20using System.Threading.Tasks;21using System.Data.OleDb;22{23 {24 public OleDbCommandFactory()25 : base(new OleDbParameterFactory())26 { }27 public override System.Data.Common.DbCommand Instantiate(string commandText)28 {29 return new OleDbCommand(commandText);30 }31 }32}33using System;34using System.Collections.Generic;35using System.Linq;36using System.Text;37using System.Threading.Tasks;38using System.Data.OleDb;39{40 {41 public override System.Data.Common.DbParameter Instantiate(string name, object value)42 {43 return new OleDbParameter(name, value);44 }45 }46}47using System;48using System.Collections.Generic;49using System.Linq;50using System.Text;51using System.Threading.Tasks;52using System.Data.OleDb;53{54 {55 public System.Data.Common.DbConnection Instantiate(string connectionString)56 {57 return new OleDbConnection(connectionString);58 }59 }60}61using System;62using System.Collections.Generic;63using System.Linq;64using System.Text;65using System.Threading.Tasks;66using System.Data.OleDb;67{68 {69 public System.Data.Common.DbConnection Instantiate(string connectionString)70 {71 return new OleDbConnection(connectionString);72 }73 }74}
OleDbExecutionEngine
Using AI Code Generation
1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6using NBi.Core.Query.Execution;7using System.Data;8using System.Data.OleDb;9using System.Data.Common;10{11 {12 static void Main(string[] args)13 {14 string connectionString = "Provider=SQLNCLI11;Server=.;Database=AdventureWorks2017;Trusted_Connection=yes";15 string query = "SELECT * FROM Person.Person";16 OleDbExecutionEngine engine = new OleDbExecutionEngine(connectionString);17 var result = engine.Execute(query);18 Console.WriteLine(result.Rows.Count);19 }20 }21}22using System;23using System.Collections.Generic;24using System.Linq;25using System.Text;26using System.Threading.Tasks;27using System.Data;28using System.Data.OleDb;29using System.Data.Common;30{31 {32 static void Main(string[] args)33 {34 string connectionString = "Provider=SQLNCLI11;Server=.;Database=AdventureWorks2017;Trusted_Connection=yes";35 string query = "SELECT * FROM Person.Person";36 OleDbConnection connection = new OleDbConnection(connectionString);37 OleDbCommand command = new OleDbCommand(query, connection);38 connection.Open();39 OleDbDataReader reader = command.ExecuteReader();40 DataTable dt = new DataTable();41 dt.Load(reader);42 Console.WriteLine(dt.Rows.Count);43 }44 }45}46using System;47using System.Collections.Generic;48using System.Linq;49using System.Text;50using System.Threading.Tasks;51using System.Data;52using System.Data.OleDb;53using System.Data.Common;54{55 {56 static void Main(string[] args)57 {58 string connectionString = "Provider=SQLNCLI11;Server=.;Database=AdventureWorks2017;Trusted_Connection=yes";59 string query = "SELECT * FROM Person.Person";60 OleDbConnection connection = new OleDbConnection(connectionString);61 OleDbDataAdapter adapter = new OleDbDataAdapter(query, connection);62 DataTable dt = new DataTable();63 adapter.Fill(dt);64 Console.WriteLine(dt.Rows.Count);65 }66 }67}68using System;
OleDbExecutionEngine
Using AI Code Generation
1using NBi.Core.Query.Execution;2using System.Data.OleDb;3using System.Data;4using System;5{6 {7 static void Main(string[] args)8 {9 var connectionString = "Provider=SQLNCLI11;Server=.;Database=AdventureWorks2012;Trusted_Connection=yes;";10 var commandText = "SELECT * FROM Person.Contact";11 var engine = new OleDbExecutionEngine(connectionString);12 var ds = engine.Execute(commandText);13 foreach (DataTable dt in ds.Tables)14 {15 Console.WriteLine(dt.TableName);16 foreach (DataRow dr in dt.Rows)17 {18 foreach (var item in dr.ItemArray)19 {20 Console.WriteLine(item);21 }22 }23 }24 Console.ReadKey();25 }26 }27}
OleDbExecutionEngine
Using AI Code Generation
1using NBi.Core.Query.Execution;2using NBi.Core.Query.Resolver;3using NBi.Core.Query.Command;4using NBi.Core.Query;5using System;6using System.Data;7using System.Data.OleDb;8using System.Data.Common;9using NBi.Core.Query.Execution.OleDb;10{11 {12 static void Main(string[] args)13 {14 var engine = new OleDbExecutionEngine();15 var command = new OleDbCommand();16 var connection = new OleDbConnection();17 var connectionStringBuilder = new OleDbConnectionStringBuilder();18 var resultSet = new OleDbResultSet();19 var resultSetBuilder = new OleDbResultSetBuilder();20 var resultSetTableFactory = new OleDbResultSetTableFactory();21 var resultSetTable = new OleDbResultSetTable();22 var resultSetTableBuilder = new OleDbResultSetTableBuilder();23 var resultSetTableCollection = new OleDbResultSetTableCollection();24 var resultSetTableCollectionBuilder = new OleDbResultSetTableCollectionBuilder();25 var resultSetRowFactory = new OleDbResultSetRowFactory();26 var resultSetRow = new OleDbResultSetRow();27 var resultSetRowBuilder = new OleDbResultSetRowBuilder();28 var resultSetColumnFactory = new OleDbResultSetColumnFactory();29 var resultSetColumn = new OleDbResultSetColumn();30 var resultSetColumnBuilder = new OleDbResultSetColumnBuilder();31 var resultSetColumnCollection = new OleDbResultSetColumnCollection();32 var resultSetColumnCollectionBuilder = new OleDbResultSetColumnCollectionBuilder();33 var resultSetValueFactory = new OleDbResultSetValueFactory();
OleDbExecutionEngine
Using AI Code Generation
1var engine = new OleDbExecutionEngine();2var result = engine.Execute("SELECT * FROM [Sheet1$]");3var builder = new OleDbCommandBuilder();4var command = builder.Build("SELECT * FROM [Sheet1$]");5var connectionStringBuilder = new OleDbConnectionStringBuilder();6var connectionString = connectionStringBuilder.Build(@"D:\1.xlsx");7var engine = new OleDbExecutionEngine();8var result = engine.Execute("SELECT * FROM [Sheet1$]", @"D:\1.xlsx");9var builder = new OleDbCommandBuilder();10var command = builder.Build("SELECT * FROM [Sheet1$]", @"D:\1.xlsx");11var connectionStringBuilder = new OleDbConnectionStringBuilder();12var connectionString = connectionStringBuilder.Build(@"D:\1.xlsx");13var engine = new OleDbExecutionEngine();14var result = engine.Execute("SELECT * FROM [Sheet1$]", @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\1.xlsx");15var builder = new OleDbCommandBuilder();16var command = builder.Build("SELECT * FROM [Sheet1$]", @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\1.xlsx");17var connectionStringBuilder = new OleDbConnectionStringBuilder();18var connectionString = connectionStringBuilder.Build(@"D:\1.xlsx");19var engine = new OleDbExecutionEngine();20var result = engine.Execute("SELECT * FROM [Sheet1$]", @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\1.xlsx", "Sheet1");21var builder = new OleDbCommandBuilder();22var command = builder.Build("
OleDbExecutionEngine
Using AI Code Generation
1var executionEngine = new OleDbExecutionEngine();2var result = executionEngine.Execute(query);3var resultSet = new OleDbResultSet(result);4var assertionEngine = new AssertionEngine();5var assertion = new RowCountAssertion(Comparison.GreaterOrEqual, 1);6assertionEngine.Assert(assertion, resultSet);
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!!