Solution.Framework.Repository 5.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Solution.Framework.Repository --version 5.0.0
                    
NuGet\Install-Package Solution.Framework.Repository -Version 5.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="Solution.Framework.Repository" Version="5.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Solution.Framework.Repository" Version="5.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Solution.Framework.Repository" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Solution.Framework.Repository --version 5.0.0
                    
#r "nuget: Solution.Framework.Repository, 5.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.
#:package Solution.Framework.Repository@5.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Solution.Framework.Repository&version=5.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Solution.Framework.Repository&version=5.0.0
                    
Install as a Cake Tool

Repository

Repository framework to access database.

Sample code

Context

ExecuteNonQuery
using Solution.Framework.Logger.Enums;
using Solution.Framework.Repository.DataLayers.Classes;
using Solution.Framework.Repository.Models;
 
class Program
{
    static void Main(string[] args)
    {
            DataLayerContext<TestDBContext> dl = new();

            dl.Init(new DataLayerConfiguration(new ConnectionData(connectionString: 
                "Server=.; Database=TestDB;Trusted_Connection=True;Application Name=Repository.Test;",
                "SqlServer"), GetConfiguration(), LogTypeEnum.Application, Environment.UserName));

            Console.WriteLine(dl.ExecuteNonQuery("Exec dbo.sp_GetUsers"));
    }
}
ExecuteScalar
using Solution.Framework.Logger.Enums;
using Solution.Framework.Repository.DataLayers.Classes;
using Solution.Framework.Repository.Models;
 
class Program
{
    static void Main(string[] args)
    {
            DataLayerContext<TestDBContext> dl = new();

            dl.Init(new DataLayerConfiguration(new ConnectionData(connectionString: 
                "Server=.; Database=TestDB;Trusted_Connection=True;Application Name=Repository.Test;",
                "SqlServer"), GetConfiguration(), LogTypeEnum.Application, Environment.UserName));

            Console.WriteLine(dl.ExecuteScalar<int>("Select Count(1) From dbo.Users;"));
    }
}
Commit
using Solution.Framework.Logger.Enums;
using Solution.Framework.Repository.DataLayers.Classes;
using Solution.Framework.Repository.Models;
 
class Program
{
    static void Main(string[] args)
    {
            DataLayerContext<TestDBContext> dl = new();

            dl.Init(new DataLayerConfiguration(new ConnectionData(connectionString: 
                "Server=.; Database=TestDB;Trusted_Connection=True;Application Name=Repository.Test;",
                "SqlServer"), GetConfiguration(), LogTypeEnum.Application, Environment.UserName));

            Users entity = dl.Repository<Users>().Add("{\"UserId\": 1, \"FirstName\": \"Name\", \"LastName\": \"Surname\" }");
            dl.Commit();
    }
}
Rollback
using Solution.Framework.Logger.Enums;
using Solution.Framework.Repository.DataLayers.Classes;
using Solution.Framework.Repository.Models;
 
class Program
{
    static void Main(string[] args)
    {
            DataLayerContext<TestDBContext> dl = new();

            dl.Init(new DataLayerConfiguration(new ConnectionData(connectionString: 
                "Server=.; Database=TestDB;Trusted_Connection=True;Application Name=Repository.Test;",
                "SqlServer"), GetConfiguration(), LogTypeEnum.Application, Environment.UserName));

            Users entity = dl.Repository<Users>().Add("{\"UserId\": 1, \"FirstName\": \"Name\", \"LastName\": \"Surname\" }");
            dl.Rollback();
    }
}

Context ViewModel

Commit
using Solution.Framework.Logger.Enums;
using Solution.Framework.Repository.DataLayers.Classes;
using Solution.Framework.Repository.Models;
 
class Program
{
    static void Main(string[] args)
    {
            DataLayerContextViewModel<TestDBContext> dl = new();
            MapperConfiguration mapperConfiguration = new(cfg =>
            {
                cfg.CreateMap<UsersViewModel, Users>().ForMember(o => o.UniqueIdentificationKey, d => d.MapFrom(s => $"{(s.UserId)}")).ReverseMap();
                cfg.CreateMap<PostsViewModel, Posts>().ForMember(o => o.UniqueIdentificationKey, d => d.MapFrom(s => $"{(s.UserId)}")).ReverseMap();
            });

            dl.Init(new DataLayerConfiguration(new ConnectionData(connectionString: 
                "Server=.; Database=TestDB;Trusted_Connection=True;Application Name=Repository.Test;",
                "SqlServer"), GetConfiguration(), LogTypeEnum.Application, Environment.UserName));

            Users entity = dl.Repository<Users, UsersViewModel>().Add("{\"UserId\": 1, \"FirstName\": \"Name\", \"LastName\": \"Surname\" }");
            dl.Commit();
    }
}

Get

Any
using Solution.Framework.Logger.Enums;
using Solution.Framework.Repository.DataLayers.Classes;
using Solution.Framework.Repository.Models;
 
class Program
{
    static void Main(string[] args)
    {
            DataLayerGet<TestDBContext, Users> dl = new();

            dl.Init(new DataLayerConfiguration(new ConnectionData(connectionString: 
                "Server=.; Database=TestDB;Trusted_Connection=True;Application Name=Repository.Test;",
                "SqlServer"), GetConfiguration(), LogTypeEnum.Application, Environment.UserName));

            Console.WriteLine(dl.Any(w => w.UserId == 1));
    }
}
GetAll
using Solution.Framework.Logger.Enums;
using Solution.Framework.Repository.DataLayers.Classes;
using Solution.Framework.Repository.Models;
 
class Program
{
    static void Main(string[] args)
    {
            DataLayerGet<TestDBContext, Users> dl = new();

            dl.Init(new DataLayerConfiguration(new ConnectionData(connectionString: 
                "Server=.; Database=TestDB;Trusted_Connection=True;Application Name=Repository.Test;",
                "SqlServer"), GetConfiguration(), LogTypeEnum.Application, Environment.UserName));

            Console.WriteLine(JsonClass.ConvertClassToJson(dl.GetAll("Posts")));
    }
}
Get
using Solution.Framework.Logger.Enums;
using Solution.Framework.Repository.DataLayers.Classes;
using Solution.Framework.Repository.Models;
 
class Program
{
    static void Main(string[] args)
    {
            DataLayerGet<TestDBContext, Users> dl = new();

            dl.Init(new DataLayerConfiguration(new ConnectionData(connectionString: 
                "Server=.; Database=TestDB;Trusted_Connection=True;Application Name=Repository.Test;",
                "SqlServer"), GetConfiguration(), LogTypeEnum.Application, Environment.UserName));

            Console.WriteLine(JsonClass.ConvertClassToJson(dl.Get(w => w.UserId == 1, "Posts")));
    }
}
GetByStoredProcedure
using Solution.Framework.Logger.Enums;
using Solution.Framework.Repository.DataLayers.Classes;
using Solution.Framework.Repository.Models;
 
class Program
{
    static void Main(string[] args)
    {
            DataLayerGet<TestDBContext, Users> dl = new();

            dl.Init(new DataLayerConfiguration(new ConnectionData(connectionString: 
                "Server=.; Database=TestDB;Trusted_Connection=True;Application Name=Repository.Test;",
                "SqlServer"), GetConfiguration(), LogTypeEnum.Application, Environment.UserName));

            Console.WriteLine(JsonClass.ConvertClassToJson(dl.GetByStoredProcedure("exec sp_GetUsers;")));
    }
}
GetDynamic
using Solution.Framework.Logger.Enums;
using Solution.Framework.Repository.DataLayers.Classes;
using Solution.Framework.Repository.Models;
 
class Program
{
    static void Main(string[] args)
    {
            DataLayerGet<TestDBContext, Users> dl = new();

            dl.Init(new DataLayerConfiguration(new ConnectionData(connectionString: 
                "Server=.; Database=TestDB;Trusted_Connection=True;Application Name=Repository.Test;",
                "SqlServer"), GetConfiguration(), LogTypeEnum.Application, Environment.UserName));

            Console.WriteLine(JsonClass.ConvertClassToJson(dl.GetDynamic($"UserId = 1", "Posts")));
    }
}
GetFirstOrDefault
using Solution.Framework.Logger.Enums;
using Solution.Framework.Repository.DataLayers.Classes;
using Solution.Framework.Repository.Models;
 
class Program
{
    static void Main(string[] args)
    {
            DataLayerGet<TestDBContext, Users> dl = new();

            dl.Init(new DataLayerConfiguration(new ConnectionData(connectionString: 
                "Server=.; Database=TestDB;Trusted_Connection=True;Application Name=Repository.Test;",
                "SqlServer"), GetConfiguration(), LogTypeEnum.Application, Environment.UserName));

            Console.WriteLine(JsonClass.ConvertClassToJson(dl.GetFirstOrDefault(w => w.FirstName == "Name", "Posts")));
    }
}

Model

Add
using Solution.Framework.Logger.Enums;
using Solution.Framework.Repository.DataLayers.Classes;
using Solution.Framework.Repository.Models;
 
class Program
{
    static void Main(string[] args)
    {
            DataLayerModel<TestDBContext, Users> dl = new();

            dl.Init(new DataLayerConfiguration(new ConnectionData(connectionString: 
                "Server=.; Database=TestDB;Trusted_Connection=True;Application Name=Repository.Test;",
                "SqlServer"), GetConfiguration(), LogTypeEnum.Application, Environment.UserName));

            Users entity = dl.Add("{\"UserId\": 1, \"FirstName\": \"Name\", \"LastName\": \"Surname\" }");
    }
}
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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 238 2/18/2024
7.0.8 251 11/23/2023
7.0.7 218 11/22/2023
7.0.6 178 11/20/2023
7.0.5 184 11/15/2023
7.0.4 178 11/15/2023
7.0.3 208 11/12/2023
7.0.2 213 9/25/2023
7.0.1 394 2/8/2023
7.0.0 399 1/24/2023
6.0.3 593 8/9/2022
6.0.2 573 8/9/2022
6.0.1 595 8/8/2022
6.0.0 579 8/8/2022
5.0.4 1,037 12/15/2021
5.0.3 842 10/25/2021
5.0.2 855 10/25/2021
5.0.1 769 10/11/2021
5.0.0 973 10/5/2021