How to use SqlCommandFactory class of NBi.Core.Query.Command package

Best NBi code snippet using NBi.Core.Query.Command.SqlCommandFactory

SqlCommandFactoryTest.cs

Source:SqlCommandFactoryTest.cs Github

copy

Full Screen

...13using NBi.Extensibility.Query;14namespace NBi.Testing.Core.Query.Command15{16 [TestFixture]17 public class SqlCommandFactoryTest18 {19 [Test]20 public void Build_TimeoutSpecified_TimeoutSet()21 {22 var conn = new DbClient(DbProviderFactories.GetFactory("System.Data.SqlClient"), typeof(SqlConnection), "Data Source=server;Initial Catalog=database;Integrated Security=SSPI");23 var query = Mock.Of<IQuery>(24 x => x.ConnectionString == "Data Source=server;Initial Catalog=database;Integrated Security=SSPI"25 && x.Statement == "WAITFOR DELAY '00:00:15'"26 && x.Timeout == new TimeSpan(0, 0, 5)27 );28 var factory = new SqlCommandFactory();29 var cmd = factory.Instantiate(conn, query, null);30 Assert.IsInstanceOf<SqlCommand>(cmd.Implementation);31 Assert.That((cmd.Implementation as SqlCommand).CommandTimeout, Is.EqualTo(5));32 }33 [Test]34 public void Build_TimeoutSetToZero_TimeoutSet0Seconds()35 {36 var conn = new DbClient(DbProviderFactories.GetFactory("System.Data.SqlClient"), typeof(SqlConnection), "Data Source=server;Initial Catalog=database;Integrated Security=SSPI");37 var query = Mock.Of<IQuery>(38 x => x.ConnectionString == "Data Source=server;Initial Catalog=database;Integrated Security=SSPI"39 && x.Statement == "WAITFOR DELAY '00:00:15'"40 && x.Timeout == new TimeSpan(0, 0, 0)41 );42 var factory = new SqlCommandFactory();43 var cmd = factory.Instantiate(conn, query, null);44 Assert.IsInstanceOf<SqlCommand>(cmd.Implementation);45 Assert.That((cmd.Implementation as SqlCommand).CommandTimeout, Is.EqualTo(0));46 }47 [Test]48 public void Build_TimeoutSetTo30_TimeoutSet30Seconds()49 {50 var conn = new DbClient(DbProviderFactories.GetFactory("System.Data.SqlClient"), typeof(SqlConnection), "Data Source=server;Initial Catalog=database;Integrated Security=SSPI");51 var query = Mock.Of<IQuery>(52 x => x.ConnectionString == "Data Source=server;Initial Catalog=database;Integrated Security=SSPI"53 && x.Statement == "WAITFOR DELAY '00:00:15'"54 && x.Timeout == new TimeSpan(0, 0, 30)55 );56 var factory = new SqlCommandFactory();57 var cmd = factory.Instantiate(conn, query, null);58 Assert.IsInstanceOf<SqlCommand>(cmd.Implementation);59 Assert.That((cmd.Implementation as SqlCommand).CommandTimeout, Is.EqualTo(30));60 }61 [Test]62 public void Build_CommandTypeSetToText_CommandTypeSetText()63 {64 var conn = new DbClient(DbProviderFactories.GetFactory("System.Data.SqlClient"), typeof(SqlConnection), "Data Source=server;Initial Catalog=database;Integrated Security=SSPI");65 var query = Mock.Of<IQuery>(66 x => x.ConnectionString == "Data Source=server;Initial Catalog=database;Integrated Security=SSPI"67 && x.CommandType == System.Data.CommandType.Text68 );69 var factory = new SqlCommandFactory();70 var cmd = factory.Instantiate(conn, query, null);71 Assert.IsInstanceOf<SqlCommand>(cmd.Implementation);72 Assert.That((cmd.Implementation as SqlCommand).CommandType, Is.EqualTo(System.Data.CommandType.Text));73 }74 [Test]75 public void Build_CommandTypeSetToStoredProcedure_CommandTypeSetStoredProcedure()76 {77 var conn = new DbClient(DbProviderFactories.GetFactory("System.Data.SqlClient"), typeof(SqlConnection), "Data Source=server;Initial Catalog=database;Integrated Security=SSPI");78 var query = Mock.Of<IQuery>(79 x => x.ConnectionString == "Data Source=server;Initial Catalog=database;Integrated Security=SSPI"80 && x.CommandType == System.Data.CommandType.StoredProcedure81 );82 var factory = new SqlCommandFactory();83 var cmd = factory.Instantiate(conn, query, null);84 Assert.IsInstanceOf<SqlCommand>(cmd.Implementation);85 Assert.That((cmd.Implementation as SqlCommand).CommandType, Is.EqualTo(System.Data.CommandType.StoredProcedure));86 }87 }88}...

Full Screen

Full Screen

CommandProvider.cs

Source:CommandProvider.cs Github

copy

Full Screen

...16 {17 typeof(AdomdCommandFactory),18 typeof(OdbcCommandFactory),19 typeof(OleDbCommandFactory),20 typeof(SqlCommandFactory)21 };22 public CommandProvider()23 {24 RegisterFactories(classics);25 }26 public CommandProvider(IExtensionsConfiguration config)27 {28 var extensions = config?.Extensions?.Where(x => typeof(ICommandFactory).IsAssignableFrom(x.Key) && !x.Key.IsAbstract)?.Select(x => x.Key) ?? new Type[0];29 RegisterFactories(classics.Union(extensions).ToArray());30 }31 protected internal void RegisterFactories(Type[] types)32 {33 foreach (var type in types)34 {...

Full Screen

Full Screen

SqlCommandFactory.cs

Source:SqlCommandFactory.cs Github

copy

Full Screen

...11using System.Threading.Tasks;12using NBi.Extensibility.Query;13namespace NBi.Core.Query.Command14{15 class SqlCommandFactory : DbCommandFactory16 {17 public override bool CanHandle(IClient client) => client.UnderlyingSessionType == typeof(SqlConnection);18 protected override string RenameParameter(string originalName)19 {20 if (!originalName.StartsWith("@") && char.IsLetter(originalName[0]))21 return "@" + originalName;22 else23 return originalName;24 }25 }26}...

Full Screen

Full Screen

SqlCommandFactory

Using AI Code Generation

copy

Full Screen

1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6using NBi.Core.Query.Command;7using System.Data.SqlClient;8{9 {10 static void Main(string[] args)11 {12 SqlCommandFactory factory = new SqlCommandFactory();13 var cmd = factory.Instantiate("SELECT * FROM [AdventureWorks2014].[Person].[Person]");14 Console.WriteLine(cmd.CommandText);15 Console.ReadLine();16 }17 }18}19using System;20using System.Collections.Generic;21using System.Linq;22using System.Text;23using System.Threading.Tasks;24using NBi.Core.Query;25using System.Data.SqlClient;26{27 {28 static void Main(string[] args)29 {30 QueryCommandFactory factory = new QueryCommandFactory();31 var cmd = factory.Instantiate("SELECT * FROM [AdventureWorks2014].[Person].[Person]");32 Console.WriteLine(cmd.CommandText);33 Console.ReadLine();34 }35 }36}37using System;38using System.Collections.Generic;39using System.Linq;40using System.Text;41using System.Threading.Tasks;42using NBi.Core.Query;43using System.Data.SqlClient;44{45 {46 static void Main(string[] args)47 {48 var factory = new QueryCommandFactory();49 var cmd = factory.Instantiate("SELECT * FROM [AdventureWorks2014].[Person].[Person]");50 Console.WriteLine(cmd.CommandText);51 Console.ReadLine();52 }53 }54}55using System;56using System.Collections.Generic;57using System.Linq;58using System.Text;59using System.Threading.Tasks;60using NBi.Core.Query;61using System.Data.SqlClient;62{63 {64 static void Main(string[] args)65 {66 var factory = new QueryCommandFactory();67 var cmd = factory.Instantiate("SELECT * FROM [AdventureWorks2014].[Person].[Person]");68 Console.WriteLine(cmd.CommandText);69 Console.ReadLine();70 }71 }72}73using System;

Full Screen

Full Screen

SqlCommandFactory

Using AI Code Generation

copy

Full Screen

1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6using NBi.Core.Query.Command;7using NBi.Core.Query;8using System.Data.SqlClient;9using System.Data;10using System.IO;11{12 {13 public SqlCommandFactory(string connectionString)14 {15 ConnectionString = connectionString;16 }17 public override IDbCommand Instantiate(string text)18 {19 var command = new SqlCommand();20 command.Connection = new SqlConnection(ConnectionString);21 command.CommandText = text;22 command.CommandType = CommandType.Text;23 return command;24 }25 }26}27using System;28using System.Collections.Generic;29using System.Linq;30using System.Text;31using System.Threading.Tasks;32using NBi.Core.Query.Command;33using NBi.Core.Query;34using System.Data.SqlClient;35using System.Data;36using System.IO;37{38 {39 public SqlCommandFactory(string connectionString)40 {41 ConnectionString = connectionString;42 }43 public override IDbCommand Instantiate(string text)44 {45 var command = new SqlCommand();46 command.Connection = new SqlConnection(ConnectionString);47 command.CommandText = text;48 command.CommandType = CommandType.Text;49 return command;50 }51 }52}53using System;54using System.Collections.Generic;55using System.Linq;56using System.Text;57using System.Threading.Tasks;58using NBi.Core.Query.Command;59using NBi.Core.Query;60using System.Data.SqlClient;61using System.Data;62using System.IO;63{64 {65 public SqlCommandFactory(string connectionString)66 {67 ConnectionString = connectionString;68 }69 public override IDbCommand Instantiate(string text)70 {71 var command = new SqlCommand();72 command.Connection = new SqlConnection(ConnectionString);73 command.CommandText = text;74 command.CommandType = CommandType.Text;75 return command;76 }77 }78}

Full Screen

Full Screen

SqlCommandFactory

Using AI Code Generation

copy

Full Screen

1using System;2using System.Data;3using System.Data.SqlClient;4using NBi.Core.Query.Command;5using NBi.Core.Query.Command.Scalar;6using NBi.Core.Query.Command.Text;7using NBi.Core.Query.Command.TimeSpan;8using NBi.Core.Query.Command.Csv;9using NBi.Core.Query.Command.CsvFile;10using NBi.Core.Query.Command.File;11using NBi.Core.Query.Command.Performance;12using NBi.Core.Query.Command.Procedure;13{14 {15 static void Main(string[] args)16 {17 string connectionString = "Data Source=localhost;Initial Catalog=AdventureWorks2014;Integrated Security=True";18 SqlCommandFactory factory = new SqlCommandFactory(connectionString);19 SqlCommand command = factory.Instantiate("select count(*) from Person.Person");20 command.Connection.Open();21 Console.WriteLine(command.ExecuteScalar());22 command.Connection.Close();23 }24 }25}26using System;27using System.Data;28using System.Data.SqlClient;29using NBi.Core.Query.Command;30using NBi.Core.Query.Command.Scalar;31using NBi.Core.Query.Command.Text;32using NBi.Core.Query.Command.TimeSpan;33using NBi.Core.Query.Command.Csv;34using NBi.Core.Query.Command.CsvFile;35using NBi.Core.Query.Command.File;36using NBi.Core.Query.Command.Performance;37using NBi.Core.Query.Command.Procedure;38{39 {40 static void Main(string[] args)41 {42 string connectionString = "Data Source=localhost;Initial Catalog=AdventureWorks2014;Integrated Security=True";43 SqlCommandFactory factory = new SqlCommandFactory(connectionString);44 SqlCommand command = factory.Instantiate("select count(*) from Person.Person");45 command.Connection.Open();46 Console.WriteLine(command.ExecuteScalar());47 command.Connection.Close();48 }49 }50}

Full Screen

Full Screen

SqlCommandFactory

Using AI Code Generation

copy

Full Screen

1using System;2using System.Data;3using System.Data.SqlClient;4using NBi.Core.Query.Command;5{6 {7 public static SqlCommand Build(string connectionString, string query)8 {9 return new SqlCommand(query, new SqlConnection(connectionString));10 }11 public static SqlCommand Build(string connectionString, string query, CommandType commandType)12 {13 var command = Build(connectionString, query);14 command.CommandType = commandType;15 return command;16 }17 }18}19using System;20using System.Collections.Generic;21using System.Linq;22using System.Text;23using System.Threading.Tasks;24using NBi.Core.Query.Client;25using NBi.Core.Query.Command;26{27 {28 public static SqlClient Build(string connectionString)29 {30 return new SqlClient(new SqlCommandFactory(), connectionString);31 }32 }33}34using System;35using System.Collections.Generic;36using System.Linq;37using System.Text;38using System.Threading.Tasks;39using NBi.Core.Query.Client;40using NBi.Core.Query.Command;41using NBi.Core.Query.Resolver;42{43 {44 public IClient Client { get; private set; }45 public SqlQueryResolver(string connectionString)46 {47 Client = new SqlClientFactory().Build(connectionString);48 }49 }50}51using System;52using System.Collections.Generic;53using System.Linq;54using System.Text;55using System.Threading.Tasks;56using NBi.Core.Query.Client;57using NBi.Core.Query.Command;58using NBi.Core.Query.Resolver;59{60 {61 public static IQuery Build(string connectionString)62 {63 return new SqlQueryResolver(connectionString);64 }65 }66}67using System;68using System.Collections.Generic;69using System.Linq;70using System.Text;71using System.Threading.Tasks;72using NBi.Core.Query.Client;73using NBi.Core.Query.Command;74using NBi.Core.Query.Resolver;75{76 {

Full Screen

Full Screen

SqlCommandFactory

Using AI Code Generation

copy

Full Screen

1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6using NBi.Core.Query.Command;7using NBi.Core.Query;8using NBi.Core.Query.Resolver;9{10 {11 static void Main(string[] args)12 {13 string connectionString = "Data Source=.;Initial Catalog=AdventureWorks2012;Integrated Security=True";14 string query = "Select * from HumanResources.Department";15 var factory = new SqlCommandFactory();16 var command = factory.Instantiate(connectionString, query);17 var resolver = new QueryResolver(command);18 var result = resolver.Execute();19 Console.WriteLine(result.Rows.Count);20 Console.ReadLine();21 }22 }23}

Full Screen

Full Screen

SqlCommandFactory

Using AI Code Generation

copy

Full Screen

1using System;2using System.Data.SqlClient;3using NBi.Core.Query;4using NBi.Core.Query.Command;5{6 {7 static void Main(string[] args)8 {9 var factory = new SqlCommandFactory();10 var command = factory.Instantiate("select * from table1");11 command.ConnectionString = "Data Source=.;Initial Catalog=Test;Integrated Security=True";12 command.Connection.Open();13 var reader = command.ExecuteReader();14 while (reader.Read())15 {16 Console.WriteLine(reader[0]);17 }18 command.Connection.Close();19 }20 }21}22 Sub Main()23 Dim factory As New SqlCommandFactory()24 Dim command As SqlCommand = factory.Instantiate("select * from table1")25 command.ConnectionString = "Data Source=.;Initial Catalog=Test;Integrated Security=True"26 command.Connection.Open()27 Dim reader As SqlDataReader = command.ExecuteReader()28 While reader.Read()29 Console.WriteLine(reader(0))30 command.Connection.Close()31using System;32using System.Data.SqlClient;33using NBi.Core.Query;34using NBi.Core.Query.Command;35{36 {37 static void Main(string[] args)38 {39 var factory = new SqlCommandFactory();40 var command = factory.Instantiate("select * from table1");41 command.ConnectionString = "Data Source=.;Initial Catalog=Test;Integrated Security=True";42 command.Connection.Open();43 var reader = command.ExecuteReader();44 while (reader.Read

Full Screen

Full Screen

SqlCommandFactory

Using AI Code Generation

copy

Full Screen

1using NBi.Core.Query.Command;2SqlCommandFactory sqlCmdFactory = new SqlCommandFactory();3SqlCommand sqlCmd = sqlCmdFactory.Instantiate("select * from table1");4SqlConnection sqlConn = new SqlConnection("connection string");5sqlConn.Open();6sqlCmd.Connection = sqlConn;7SqlDataReader sqlReader = sqlCmd.ExecuteReader();8while (sqlReader.Read())9{10 Console.WriteLine(sqlReader["column1"].ToString());11}12sqlReader.Close();13sqlConn.Close();14using NBi.Core.Query;15SqlCommandFactory sqlCmdFactory = new SqlCommandFactory();16SqlCommand sqlCmd = sqlCmdFactory.Instantiate("select * from table1");17SqlConnection sqlConn = new SqlConnection("connection string");18sqlConn.Open();19sqlCmd.Connection = sqlConn;20SqlDataReader sqlReader = sqlCmd.ExecuteReader();21while (sqlReader.Read())22{23 Console.WriteLine(sqlReader["column1"].ToString());24}25sqlReader.Close();26sqlConn.Close();27using NBi.Core;28SqlCommandFactory sqlCmdFactory = new SqlCommandFactory();29SqlCommand sqlCmd = sqlCmdFactory.Instantiate("select * from table1");30SqlConnection sqlConn = new SqlConnection("connection string");31sqlConn.Open();32sqlCmd.Connection = sqlConn;33SqlDataReader sqlReader = sqlCmd.ExecuteReader();

Full Screen

Full Screen

SqlCommandFactory

Using AI Code Generation

copy

Full Screen

1using NBi.Core.Query.Command;2using System.Data.SqlClient;3using System;4using System.Data;5{6 {7 static void Main(string[] args)8 {9 string connectionString = "Data Source=.;Initial Catalog=AdventureWorks2012;Integrated Security=True";10 string commandText = "SELECT * FROM [Production].[Product]";11 using (var connection = new SqlConnection(connectionString))12 {13 connection.Open();14 var factory = new SqlCommandFactory();15 var command = factory.Instantiate(commandText, connection);16 command.CommandType = CommandType.Text;17 var reader = command.ExecuteReader();18 while (reader.Read())19 {20 Console.WriteLine(reader["Name"]);21 }22 }23 }24 }25}26using NBi.Core.Query.Command;27using System.Data.SqlClient;28using System;29using System.Data;30{31 {32 static void Main(string[] args)33 {34 string connectionString = "Data Source=.;Initial Catalog=AdventureWorks2012;Integrated Security=True";35 string commandText = "SELECT * FROM [Production].[Product]";36 using (var connection = new SqlConnection(connectionString))37 {38 connection.Open();39 var factory = new SqlCommandFactory();40 var command = factory.Instantiate(commandText, connection);41 command.CommandType = CommandType.Text;42 var reader = command.ExecuteReader();43 while (reader.Read())44 {45 Console.WriteLine(reader["Name"]);46 }47 }48 }49 }50}51using NBi.Core.Query.Command;52using System.Data.SqlClient;53using System;54using System.Data;55{56 {57 static void Main(string[] args)58 {59 string connectionString = "Data Source=.;Initial Catalog=AdventureWorks2012;Integrated Security=True";60 string commandText = "SELECT * FROM [Production].[Product]";61 using (var connection = new SqlConnection(connectionString))62 {63 connection.Open();64 var factory = new SqlCommandFactory();65 var command = factory.Instantiate(commandText, connection);66 command.CommandType = CommandType.Text;67 var reader = command.ExecuteReader();68 while (reader.Read())

Full Screen

Full Screen

SqlCommandFactory

Using AI Code Generation

copy

Full Screen

1using System;2using System.Data;3using System.Data.SqlClient;4using System.IO;5using NBi.Core.Query.Command;6using System.Collections.Generic;7using System.Linq;8using System.Text;9using System.Threading.Tasks;10{11 {12 static void Main(string[] args)13 {14 var commandFactory = new SqlCommandFactory();15 string query = "SELECT * FROM [dbo].[Table1]";16 SqlCommand command = commandFactory.Instantiate(query);17 SqlConnection connection = new SqlConnection();18 connection.ConnectionString = "Data Source=.;Initial Catalog=TestDB;Integrated Security=True";19 command.Connection = connection;20 SqlDataAdapter adapter = new SqlDataAdapter();21 adapter.SelectCommand = command;22 DataTable table = new DataTable();23 adapter.Fill(table);24 StringBuilder sb = new StringBuilder();25 Select(column => column.ColumnName);26 sb.AppendLine(string.Join(",", columnNames));27 foreach (DataRow row in table.Rows)28 {29 IEnumerable<string> fields = row.ItemArray.Select(field => field.ToString());30 sb.AppendLine(string.Join(",", fields));31 }32 StreamWriter sw = new StreamWriter("C:\\Users\\Public\\Test.csv");33 sw.Write(sb.ToString());34 sw.Close();35 }36 }37}38sqlConn.Close();39using NBi.Core;40SqlCommandFactory sqlCmdFactory = new SqlCommandFactory();41SqlCommand sqlCmd = sqlCmdFactory.Instantiate("select * from table1");42SqlConnection sqlConn = new SqlConnection("connection string");43sqlConn.Open();44sqlCmd.Connection = sqlConn;45SqlDataReader sqlReader = sqlCmd.ExecuteReader();

Full Screen

Full Screen

SqlCommandFactory

Using AI Code Generation

copy

Full Screen

1using NBi.Core.Query.Command;2using System.Data.SqlClient;3using System;4using System.Data;5{6 {7 static void Main(string[] args)8 {9 string connectionString = "Data Source=.;Initial Catalog=AdventureWorks2012;Integrated Security=True";10 string commandText = "SELECT * FROM [Production].[Product]";11 using (var connection = new SqlConnection(connectionString))12 {13 connection.Open();14 var factory = new SqlCommandFactory();15 var command = factory.Instantiate(commandText, connection);16 command.CommandType = CommandType.Text;17 var reader = command.ExecuteReader();18 while (reader.Read())19 {20 Console.WriteLine(reader["Name"]);21 }22 }23 }24 }25}26using NBi.Core.Query.Command;27using System.Data.SqlClient;28using System;29using System.Data;30{31 {32 static void Main(string[] args)33 {34 string connectionString = "Data Source=.;Initial Catalog=AdventureWorks2012;Integrated Security=True";35 string commandText = "SELECT * FROM [Production].[Product]";36 using (var connection = new SqlConnection(connectionString))37 {38 connection.Open();39 var factory = new SqlCommandFactory();40 var command = factory.Instantiate(commandText, connection);41 command.CommandType = CommandType.Text;42 var reader = command.ExecuteReader();43 while (reader.Read())44 {45 Console.WriteLine(reader["Name"]);46 }47 }48 }49 }50}51using NBi.Core.Query.Command;52using System.Data.SqlClient;53using System;54using System.Data;55{56 {57 static void Main(string[] args)58 {59 string connectionString = "Data Source=.;Initial Catalog=AdventureWorks2012;Integrated Security=True";60 string commandText = "SELECT * FROM [Production].[Product]";61 using (var connection = new SqlConnection(connectionString))62 {63 connection.Open();64 var factory = new SqlCommandFactory();65 var command = factory.Instantiate(commandText, connection);66 command.CommandType = CommandType.Text;67 var reader = command.ExecuteReader();68 while (reader.Read())

Full Screen

Full Screen

SqlCommandFactory

Using AI Code Generation

copy

Full Screen

1using System;2using System.Data;3using System.Data.SqlClient;4using System.IO;5using NBi.Core.Query.Command;6using System.Collections.Generic;7using System.Linq;8using System.Text;9using System.Threading.Tasks;10{11 {12 static void Main(string[] args)13 {14 var commandFactory = new SqlCommandFactory();15 string query = "SELECT * FROM [dbo].[Table1]";16 SqlCommand command = commandFactory.Instantiate(query);17 SqlConnection connection = new SqlConnection();18 connection.ConnectionString = "Data Source=.;Initial Catalog=TestDB;Integrated Security=True";19 command.Connection = connection;20 SqlDataAdapter adapter = new SqlDataAdapter();21 adapter.SelectCommand = command;22 DataTable table = new DataTable();23 adapter.Fill(table);24 StringBuilder sb = new StringBuilder();25 Select(column => column.ColumnName);26 sb.AppendLine(string.Join(",", columnNames));27 foreach (DataRow row in table.Rows)28 {29 IEnumerable<string> fields = row.ItemArray.Select(field => field.ToString());30 sb.AppendLine(string.Join(",", fields));31 }32 StreamWriter sw = new StreamWriter("C:\\Users\\Public\\Test.csv");33 sw.Write(sb.ToString());34 sw.Close();35 }36 }37}38using System;39using System.Collections.Generic;40using System.Linq;41using System.Text;42using System.Threading.Tasks;43using NBi.Core.Query.Command;44using NBi.Core.Query;45using System.Data.SqlClient;46using System.Data;47using System.IO;48{49 {50 public SqlCommandFactory(string connectionString)51 {52 ConnectionString = connectionString;53 }54 public override IDbCommand Instantiate(string text)55 {56 var command = new SqlCommand();57 command.Connection = new SqlConnection(ConnectionString);58 command.CommandText = text;59 command.CommandType = CommandType.Text;60 return command;61 }62 }63}64using System;65using System.Collections.Generic;66using System.Linq;67using System.Text;68using System.Threading.Tasks;69using NBi.Core.Query.Command;70using NBi.Core.Query;71using System.Data.SqlClient;72using System.Data;73using System.IO;74{75 {76 public SqlCommandFactory(string connectionString)77 {78 ConnectionString = connectionString;79 }80 public override IDbCommand Instantiate(string text)81 {82 var command = new SqlCommand();83 command.Connection = new SqlConnection(ConnectionString);84 command.CommandText = text;85 command.CommandType = CommandType.Text;86 return command;87 }88 }89}

Full Screen

Full Screen

SqlCommandFactory

Using AI Code Generation

copy

Full Screen

1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6using NBi.Core.Query.Command;7using NBi.Core.Query;8using NBi.Core.Query.Resolver;9{10 {11 static void Main(string[] args)12 {13 string connectionString = "Data Source=.;Initial Catalog=AdventureWorks2012;Integrated Security=True";14 string query = "Select * from HumanResources.Department";15 var factory = new SqlCommandFactory();16 var command = factory.Instantiate(connectionString, query);17 var resolver = new QueryResolver(command);18 var result = resolver.Execute();19 Console.WriteLine(result.Rows.Count);20 Console.ReadLine();21 }22 }23}

Full Screen

Full Screen

SqlCommandFactory

Using AI Code Generation

copy

Full Screen

1using System;2using System.Data;3using System.Data.SqlClient;4using System.IO;5using NBi.Core.Query.Command;6using System.Collections.Generic;7using System.Linq;8using System.Text;9using System.Threading.Tasks;10{11 {12 static void Main(string[] args)13 {14 var commandFactory = new SqlCommandFactory();15 string query = "SELECT * FROM [dbo].[Table1]";16 SqlCommand command = commandFactory.Instantiate(query);17 SqlConnection connection = new SqlConnection();18 connection.ConnectionString = "Data Source=.;Initial Catalog=TestDB;Integrated Security=True";19 command.Connection = connection;20 SqlDataAdapter adapter = new SqlDataAdapter();21 adapter.SelectCommand = command;22 DataTable table = new DataTable();23 adapter.Fill(table);24 StringBuilder sb = new StringBuilder();25 Select(column => column.ColumnName);26 sb.AppendLine(string.Join(",", columnNames));27 foreach (DataRow row in table.Rows)28 {29 IEnumerable<string> fields = row.ItemArray.Select(field => field.ToString());30 sb.AppendLine(string.Join(",", fields));31 }32 StreamWriter sw = new StreamWriter("C:\\Users\\Public\\Test.csv");33 sw.Write(sb.ToString());34 sw.Close();35 }36 }37}

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run NBi automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used methods in SqlCommandFactory

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful