ASql 1.0.1
.NET 6.0
This package targets .NET 6.0. The package is compatible with this framework or higher.
.NET Standard 2.0
This package targets .NET Standard 2.0. The package is compatible with this framework or higher.
.NET Framework 4.6.2
This package targets .NET Framework 4.6.2. The package is compatible with this framework or higher.
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package ASql --version 1.0.1
NuGet\Install-Package ASql -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ASql" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ASql --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: ASql, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install ASql as a Cake Addin #addin nuget:?package=ASql&version=1.0.1 // Install ASql as a Cake Tool #tool nuget:?package=ASql&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
ASql
C# Library that let use multiple types of databases with same code
The supported databases are SqlServer and Oracle
You only have to declare wich type of database would like you use and use the classe in the same way of sql or oracle client.
Here you can find examples :
# Example 1 Basic query
public void ExecuteQuery(ASqlManager.DBType dBType, string ConnectionString, string sql)
{
//You only have to specify which type of database want to use and after you will have to use ASql objects instead the Typized objects like OracleConnection
ASqlManager.DataBaseType = dBType;
using (ASqlConnection conn = new ASqlConnection(ConnectionString))
{
int i = 0;
conn.Open();
ASqlCommand cmd = new ASqlCommand(sql, conn);
i = cmd.ExecuteNonQuery();
}
}
# Example 2.a Query with ExecuteScalar With Parameters
public void ExecuteScalar(ASqlManager.DBType dBType, string ConnectionString)
{
string sql = "select firstname from person where lastname = @lastname";
//if you want to use oracle you have tu put : intestad @ like this
//string sql = "select firstname from person where lastname = :lastname";
ASqlManager.DataBaseType = dBType;
using (ASqlConnection conn = new ASqlConnection(ConnectionString))
{
string name = "";
conn.Open();
ASqlCommand cmd = new ASqlCommand(sql, conn);
ASqlParameter par = new ASqlParameter();
par.ParameterName = "lastname";
par.DbType = DbType.String;
par.Value = "last1";
//Pay attention to popolate the aSqlParameters collection like the row below and not the Parameters collection (the library will think to keep uptodated the Parameters collection)
cmd.aSqlParameters.Add(par);
name = (string)cmd.ExecuteScalar();
}
}
# Example 2.b with ExecuteReader With Parameters
public void ExecuteReaderTester(ASqlManager.DBType dBType)
{
string sql = "select firstname from person where lastname = @lastname";
//if you want to use oracle you have tu put : intestad @ like this
//string sql = "select firstname from person where lastname = :lastname";
ASqlManager.DataBaseType = dBType;
using (ASqlConnection conn = new ASqlConnection(ConnectionString))
{
string i = "";
conn.Open();
ASqlCommand cmd = new ASqlCommand(sql, conn);
ASqlParameter par = new ASqlParameter();
par.ParameterName = "lastname";
par.DbType = DbType.String;
par.Value = "last1";
cmd.aSqlParameters.Add(par);
using (DbDataReader read = cmd.ExecuteReader())
{
while (read.Read())
{
i = read.GetString(read.GetOrdinal("firstname"));
}
}
Assert.AreEqual("first1", i.ToUpper());
}
}
# Example 3 Using DataAdapter
public void SqlDataAdapterTester(ASqlManager.DBType dBType)
{
ASqlManager.DataBaseType = dBType;
string sql = "select * from person"
using (ASqlConnection conn = new ASqlConnection(ConnectionString))
{
int i = 0;
conn.Open();
ASqlCommand cmd = new ASqlCommand(sql, conn);
ASqlDataAdapter aSqlDataAdapter = new ASqlDataAdapter(cmd);
DataSet ds = new DataSet();
i = aSqlDataAdapter.Fill(ds);
}
}
# Example 4 using Transaction
public void DropTableWithRollBack(ASqlManager.DBType dBType, string ConnectionString, string sql)
{
ASqlManager.DataBaseType = dBType;
using (ASqlConnection conn = new ASqlConnection(ConnectionString))
{
int i = 0;
conn.Open();
DbTransaction trans = conn.BeginTransaction();
ASqlCommand cmd = new ASqlCommand(sql, conn);
cmd.Transaction = trans;
i = cmd.ExecuteNonQuery();
trans.Rollback();
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net461 was computed. net462 is compatible. net463 was computed. net47 was computed. net471 is compatible. net472 was computed. net48 is compatible. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETFramework 4.6.2
- Oracle.ManagedDataAccess (>= 21.15.0)
- System.Data.SqlClient (>= 4.8.6)
-
.NETFramework 4.7.1
- Oracle.ManagedDataAccess (>= 21.15.0)
- System.Data.SqlClient (>= 4.8.6)
-
.NETFramework 4.8
- Oracle.ManagedDataAccess (>= 21.15.0)
- System.Data.SqlClient (>= 4.8.6)
-
.NETStandard 2.0
- Oracle.ManagedDataAccess (>= 21.15.0)
- System.Data.SqlClient (>= 4.8.6)
-
.NETStandard 2.1
- Oracle.ManagedDataAccess (>= 21.15.0)
- System.Data.SqlClient (>= 4.8.6)
-
net6.0
- Oracle.ManagedDataAccess (>= 21.15.0)
- System.Data.SqlClient (>= 4.8.6)
-
net7.0
- Oracle.ManagedDataAccess (>= 21.15.0)
- System.Data.SqlClient (>= 4.8.6)
-
net8.0
- Oracle.ManagedDataAccess (>= 21.15.0)
- Oracle.ManagedDataAccess.Core (>= 23.5.1)
- System.Data.SqlClient (>= 4.8.6)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on ASql:
Package | Downloads |
---|---|
Serilog.Sinks.Database
Serilog sink that writes in one of these five databases (SqlServer, Oracle, MySql, PostgreSQL, Sqlite) |
GitHub repositories
This package is not used by any popular GitHub repositories.