SaltFramework 1.1.0
dotnet add package SaltFramework --version 1.1.0
NuGet\Install-Package SaltFramework -Version 1.1.0
<PackageReference Include="SaltFramework" Version="1.1.0" />
<PackageVersion Include="SaltFramework" Version="1.1.0" />
<PackageReference Include="SaltFramework" />
paket add SaltFramework --version 1.1.0
#r "nuget: SaltFramework, 1.1.0"
#addin nuget:?package=SaltFramework&version=1.1.0
#tool nuget:?package=SaltFramework&version=1.1.0
You can do all the CRUD operation using this library.
Just follow the step.
Step 1: Create Repository class for your operation (e.g: AccountRepository) just inherit from RepositoryBase Class shown as below
public class AccountRepository : RepositoryBase<AccountModel> {
} Step 2: Create DbContext class and inherit from DbContext (Entity Framework)
public class RepositoryContext: DbContext { public RepositoryContext(DbContextOptions options):base(options) {
} }
Step 3: Pass the context class in the constructor of Repository class shown as below.
public class AccountRepository : RepositoryBase<Account> { public AccountRepository(RepositoryContext repositoryContext) : base(repositoryContext) { } } note: Here <Account> is a DTO class
Step 4: Provide dependency injection in startup.cs
public void ConfigureServices(IServiceCollection services) { services.AddTransient<AccountRepository>(); }
Step 5: Just use your operation on controller shown as below
[Route("api/[controller]")] public class AccountController : BaseController { private readonly AccountRepository _accountRepository; public AccountController(AccountRepository accountRepository) { this._accountRepository = accountRepository; }
[HttpPost] [Route("user")] public IActionResult ValidateUser([FromBody]Account account) { var data = _accountRepository.FindByCondition(x ⇒ x.UserName == account.UserName && x.Password == account.Password).FirstOrDefault(); } public ActionResult AddAccount([FromBody]Account account) { _accountRepository.Create(account); _accountRepository.Save(); } }
Benefit of using this library:
- You don't have to create separate repository for every operation.
- Code is reduced by just injecting the Repository class.
- Clean code
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. 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. |
.NET Core | netcoreapp2.1 is compatible. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
-
.NETCoreApp 2.1
- Microsoft.EntityFrameworkCore (>= 2.1.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.