SqlClientCoreTool 8.0.0

dotnet add package SqlClientCoreTool --version 8.0.0
NuGet\Install-Package SqlClientCoreTool -Version 8.0.0
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="SqlClientCoreTool" Version="8.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SqlClientCoreTool --version 8.0.0
#r "nuget: SqlClientCoreTool, 8.0.0"
#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 SqlClientCoreTool as a Cake Addin
#addin nuget:?package=SqlClientCoreTool&version=8.0.0

// Install SqlClientCoreTool as a Cake Tool
#tool nuget:?package=SqlClientCoreTool&version=8.0.0

Getting Started Getting Started

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

  • net8.0 (For projects in .net 7 use Version 7.00)
  • System.Data.SqlClient (>= 4.8.6)

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 Compatible and additional computed target framework versions.
.NET 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
8.0.0 46 5/16/2024
7.0.4 174 5/5/2023
7.0.3 252 3/8/2023
7.0.2 225 3/2/2023
7.0.1 263 2/26/2023
7.0.0 251 2/24/2023
6.0.1 458 6/30/2022
1.2.0 377 8/13/2021
1.1.8 387 6/19/2021
1.1.7 363 6/19/2021
1.1.6 397 6/15/2021
1.1.5 399 10/10/2020
1.1.4 412 10/10/2020

Upgrade to .Net 8.
Database backup issue for Express edition.