CFDataAccess 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package CFDataAccess --version 1.0.0                
NuGet\Install-Package CFDataAccess -Version 1.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="CFDataAccess" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CFDataAccess --version 1.0.0                
#r "nuget: CFDataAccess, 1.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 CFDataAccess as a Cake Addin
#addin nuget:?package=CFDataAccess&version=1.0.0

// Install CFDataAccess as a Cake Tool
#tool nuget:?package=CFDataAccess&version=1.0.0                

CFDataAccess

CFDataAccess is a simple and efficient data access library for interacting with SQL databases. It simplifies common database operations, making it easier to perform CRUD operations and more, using C#.

Features

  • Easy-to-use API for SQL database interaction
  • Support for parameterized queries
  • Connection management
  • Built-in support for common data access patterns
  • Compatible with .NET 8.0 and later

Installation

You can install this library via NuGet Package Manager or using the .NET CLI:

NuGet Package Manager:

In Visual Studio, go to ToolsNuGet Package ManagerManage NuGet Packages for Solution, and search for CFDataAccess.

.NET CLI:

dotnet add package CFDataAccess

Package Manager Console:

Install-Package CFDataAccess

Usage

Here's an example of how to use CFDataAccess to perform basic CRUD operations:

1. Basic Setup

First, set up your connection string in your application’s configuration:

{
   "ConnectionStrings": {
     "DefaultConnection": "Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;"
   }
}
2. Example Code
using CFDataAccess;
using System.Data.SqlClient;
using System.Threading.Tasks;
using System.Collections.Generic;

public class ExampleUsage
{
 private readonly DataAccess _dataAccess;

 public ExampleUsage(string connectionString)
 {
     _dataAccess = new DataAccess(connectionString);
 }

 // Retrieve data from the database
 public async Task<List<User>> GetUsersAsync()
 {
     var sql = "SELECT * FROM Users";
     return await _dataAccess.QueryAsync<User>(sql);
 }

 // Insert data into the database
 public async Task<int> AddUserAsync(User user)
 {
     var sql = "INSERT INTO Users (Name, Age) VALUES (@Name, @Age)";
     var parameters = new[]
     {
         new SqlParameter("@Name", user.Name),
         new SqlParameter("@Age", user.Age)
     };
     return await _dataAccess.ExecuteAsync(sql, parameters);
 }
}
3. Supported Methods
  • QueryAsync<T>(): Executes a query and maps the result to a list of the specified type.
  • ExecuteAsync(): Executes a command that modifies data (e.g., INSERT, UPDATE, DELETE).
  • Transaction support: Easily handle database transactions.

License

This project is licensed under the MIT License.

Contributing:

Feel free to submit issues and pull requests! Contributions are welcome. Repository The source code for this library is available at: https://github.com/goldi0002/CFDataAccess

Instructions:

  1. Copy the above content into a text file.
  2. Save the file as README.md in the root of your project directory or repository.

This will ensure your project has a properly formatted README.md file that is easy

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
1.1.2 91 10/10/2024
1.1.1 114 10/10/2024
1.1.0 122 10/10/2024
1.0.0 91 10/10/2024