VersaTul.Data.Contracts
1.0.13
Prefix Reserved
dotnet add package VersaTul.Data.Contracts --version 1.0.13
NuGet\Install-Package VersaTul.Data.Contracts -Version 1.0.13
<PackageReference Include="VersaTul.Data.Contracts" Version="1.0.13" />
paket add VersaTul.Data.Contracts --version 1.0.13
#r "nuget: VersaTul.Data.Contracts, 1.0.13"
// Install VersaTul.Data.Contracts as a Cake Addin #addin nuget:?package=VersaTul.Data.Contracts&version=1.0.13 // Install VersaTul.Data.Contracts as a Cake Tool #tool nuget:?package=VersaTul.Data.Contracts&version=1.0.13
VersaTul Data Contracts
VersaTul Data Contracts is a project that provides generic interfaces for data manipulation in the VersaTul ecosystem. These interfaces are mainly database-oriented and can be implemented by developers who want to customize the behavior of the data projects.
Installation
To use VersaTul Data Contracts, you need to install it using nuget:
nuget install VersaTul.Data.Contracts
Usage
VersaTul Data Contracts defines the following interfaces:
IDataConnection
: Represents the database connection details needed to connect to a database.IRepository<TEntity, TKey>
: Represents a collection of functionality that can be performed on a data store.IUnitOfWork
: Represents the absolute unit of work to be sent to a database.
Each interface has several overloaded methods that allow you to perform various operations on the data. For example, you can use the IRepository<TEntity, TKey>
interface to add, find, get, update, or remove entities from the data store. You can also use the IUnitOfWork
interface to commit or rollback the changes made by the repository.
For a detailed description of each interface and method, please refer to the documentation.
Example
Here is an example of how to use VersaTul Data Contracts with VersaTul.Data.EFCore, a project that implements the interfaces using Entity Framework Core.
// Create a data connection with the connection string and provider name
IDataConnection dataConnection = new DataConnection("Server=(localdb)\\mssqllocaldb;Database=MyDatabase;Trusted_Connection=True;", "Microsoft.EntityFrameworkCore.SqlServer");
// Create a unit of work with the data connection
IUnitOfWork unitOfWork = new UnitOfWork(dataConnection);
// Get the repository for the Customer entity
IRepository<Customer, int> customerRepository = unitOfWork.GetRepository<Customer, int>();
// Add a new customer to the data store
Customer newCustomer = customerRepository.Add(new Customer { Name = "Alice", Email = "alice@example.com" });
// Save the changes to the database
unitOfWork.Commit();
// Find a customer by id
Customer existingCustomer = customerRepository.Find(1);
// Update the customer's name
existingCustomer.Name = "Bob";
// Save the changes to the database
unitOfWork.Commit();
// Remove the customer from the data store
customerRepository.Remove(existingCustomer);
// Save the changes to the database
unitOfWork.Commit();
License
VersaTul Data Contracts is licensed under the MIT License.
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. net9.0 is compatible. |
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages (2)
Showing the top 2 NuGet packages that depend on VersaTul.Data.Contracts:
Package | Downloads |
---|---|
VersaTul.Data.Sql
The VersaTul Data Sql project provides the ability to quickly create database access objects, usable on any suppporting SQL databases. This project is built on top of the System.Data.Common namespace and provides the functionality to quickly call stored procedures or plain text sql queries, then map the result into data objects using the provided helper methods. |
|
VersaTul.Data.EFCore
The VersaTul EFCore project provides the ability to quickly create project specific database repositories running on Microsoft Entity Framework Core ORM. This project provides generic repository functionality that can be reused to create project specific repositories. CRUD operations are defined both Synchronous and Asynchronous methods. |
GitHub repositories
This package is not used by any popular GitHub repositories.