SqlClientCoreTool 7.0.3
See the version list below for details.
dotnet add package SqlClientCoreTool --version 7.0.3
NuGet\Install-Package SqlClientCoreTool -Version 7.0.3
<PackageReference Include="SqlClientCoreTool" Version="7.0.3" />
paket add SqlClientCoreTool --version 7.0.3
#r "nuget: SqlClientCoreTool, 7.0.3"
// Install SqlClientCoreTool as a Cake Addin
#addin nuget:?package=SqlClientCoreTool&version=7.0.3
// Install SqlClientCoreTool as a Cake Tool
#tool nuget:?package=SqlClientCoreTool&version=7.0.3
What is this project about?
SqlClientCoreTool is a class library implemented in c#. It contains several methods for the most common interactions between SQL and .Net apps. It can be used in small projects where the complexity of current frameworks is not required. In addition to CRUD operations, there are a group of methods born from the experience of working with databases, such as creating backups, saving session data or converting images.
Dependencies
In current version
- net7.0 (For projects in .net 6 use Version 6.00)
- System.Data.SqlClient (>= 4.8.5)
How it works?
After installing the Nuget package we will be able to use the DataGather class. Through this, the most common CRUD operations can be performed.
using SqlClientCoreTool;
...
CRUD examples
Multiple Insert example
public async Task InsertListAsyn(List<User> users)
{
DataGather dg = DataGather.GetInstance(ConnectionString);
await dg.InsertListAsync(users);
}
Simple update example
We don't need to specify the name of the table if it matches the object type. Table must have a primary key
public async Task UpdateAsync(User user)
{
DataGather dg = DataGather.GetInstance(ConnectionString);
await dg.UpdateAsync(user);
}
Delete range example
Removes a ragne of rows. The table must have a primary key
public async Task UpdateAsync(List<User> user, string tableName)
{
DataGather dg = DataGather.GetInstance(ConnectionString);
await dg.DeleteRangeAsync(users, tableName);
}
Other examples
Change current database
In the example we change the connection to a diferent database
public static bool ChangeDatabase(string dbName)
{
try
{
DataGather dataGather = DataGather.GetInstance(ConnectionString, dbName);
CurrentDatabase currentDatabase = CurrentDatabase.Get(dataGather);
return currentDatabase.Name == dbName;
}
catch(Exception ex)
{
return false;
}
}
Create backup
Backup current dababase
public static bool TestBackupDatabase(string path)
{
try
{
DataGather dataGather = DataGather.GetInstance(ConnectionString);
CurrentDatabase currentDatabase = CurrentDatabase.Get(dataGather);
currentDatabase.BackupWithCompression(path);
}
catch (Exception ex)
{
return false;
}
return true;
}
Summary
Other examples can be found on GitHub.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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 was computed. 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. |
-
net7.0
- System.Data.SqlClient (>= 4.8.5)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Change project url