CFDataAccess 1.1.2
dotnet add package CFDataAccess --version 1.1.2
NuGet\Install-Package CFDataAccess -Version 1.1.2
<PackageReference Include="CFDataAccess" Version="1.1.2" />
paket add CFDataAccess --version 1.1.2
#r "nuget: CFDataAccess, 1.1.2"
// Install CFDataAccess as a Cake Addin #addin nuget:?package=CFDataAccess&version=1.1.2 // Install CFDataAccess as a Cake Tool #tool nuget:?package=CFDataAccess&version=1.1.2
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 Tools → NuGet Package Manager → Manage 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:
- Copy the above content into a text file.
- 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 | Versions 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. |
-
net8.0
- System.Data.SqlClient (>= 4.8.6)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.