![]() |
VOOZH | about |
dotnet add package TakasakiStudio.Lina.Database --version 3.0.0
NuGet\Install-Package TakasakiStudio.Lina.Database -Version 3.0.0
<PackageReference Include="TakasakiStudio.Lina.Database" Version="3.0.0" />
<PackageVersion Include="TakasakiStudio.Lina.Database" Version="3.0.0" />Directory.Packages.props
<PackageReference Include="TakasakiStudio.Lina.Database" />Project file
paket add TakasakiStudio.Lina.Database --version 3.0.0
#r "nuget: TakasakiStudio.Lina.Database, 3.0.0"
#:package TakasakiStudio.Lina.Database@3.0.0
#addin nuget:?package=TakasakiStudio.Lina.Database&version=3.0.0Install as a Cake Addin
#tool nuget:?package=TakasakiStudio.Lina.Database&version=3.0.0Install as a Cake Tool
A framework to simplify application creation by improving dependency injection, validation, config and database handling
using Config.Net;
using TakasakiStudio.Lina.AutoDependencyInjection;
using TakasakiStudio.Lina.AutoDependencyInjection.Attributes;
using TakasakiStudio.Lina.Utils.LoaderConfig;
using Microsoft.Extensions.DependencyInjection;
var serviceCollection = new ServiceCollection();
serviceCollection.AddLoaderConfig<IAppConfig>();
serviceCollection.AddAutoDependencyInjection<Program>();
var services = serviceCollection.BuildServiceProvider();
services.GetRequiredService<IFooService>().PrintAppName();
public interface IFooService
{
public void PrintAppName();
}
[Service<IFooService>]
public class FooService : IFooService
{
private readonly IAppConfig _appConfig;
public FooService(IAppConfig appConfig)
{
_appConfig = appConfig;
}
public void PrintAppName()
{
Console.WriteLine(_appConfig.AppName);
}
}
public interface IAppConfig
{
[Option(DefaultValue = "Test")]
public string AppName { get; }
}
using Config.Net;
using TakasakiStudio.Lina.Utils.LoaderConfig;
using Microsoft.Extensions.DependencyInjection;
var serviceCollection = new ServiceCollection();
var config = serviceCollection.AddLoaderConfig<IAppConfig>();
Console.WriteLine(config.AppName); // instant use
var services = serviceCollection.BuildServiceProvider();
Console.WriteLine(services.GetRequiredService<IAppConfig>().AppName); // DI usage
public interface IAppConfig
{
[Option(DefaultValue = "Test")]
public string AppName { get; }
}
using Config.Net;
using TakasakiStudio.Lina.Database;
using TakasakiStudio.Lina.Database.Models;
using TakasakiStudio.Lina.Utils.LoaderConfig;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.Extensions.DependencyInjection;
var serviceCollection = new ServiceCollection();
var config = serviceCollection.AddLoaderConfig<IAppConfig>();
serviceCollection.AddLinaDbContext<Program>((builder, assembly) =>
builder.UseMySql(config.DatabaseUrl, ServerVersion.AutoDetect(config.DatabaseUrl),
optionsBuilder => optionsBuilder.MigrationsAssembly(assembly)));
public interface IAppConfig
{
[Option(DefaultValue = "Server=localhost;Database=test;User Id=root;Password=root;")]
public string DatabaseUrl { get; }
}
public class User : BaseEntity<int>
{
public string Name { get; set; } = string.Empty;
}
public class UserConfiguration : IEntityTypeConfiguration<User>
{
public void Configure(EntityTypeBuilder<User> builder)
{
builder.ToTable("Users");
builder.HasKey(x => x.Id);
builder.Property(x => x.Name).IsRequired();
}
}
using FluentValidation;
using TakasakiStudio.Lina.Common;
using TakasakiStudio.Lina.Common.Extensions;
using TakasakiStudio.Lina.Database.Models;
var user = new User()
{
Name = "",
Cpf = "",
Cnpj = "",
};
if (!await user.IsValid())
{
Console.WriteLine("invalid");
}
user.Name = "Foo";
user.Cpf = "349.306.930-80";
user.Cnpj = "82.099.001/0001-08";
await user.Validate();
Console.WriteLine("Valid");
public class User : BaseValidated<User>
{
public required string Name { get; set; }
public required string Cpf { get; set; }
public required string Cnpj { get; set; }
protected override void SetupValidator(LinaAbstractValidator<User> rules)
{
rules.RuleFor(x => x.Name).NotEmpty();
rules.RuleFor(x => x.Cpf).ValidCpf();
rules.RuleFor(x => x.Cnpj).ValidCnpj();
}
}
using Config.Net;
using FluentValidation;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.Extensions.DependencyInjection;
using TakasakiStudio.Lina.AutoDependencyInjection;
using TakasakiStudio.Lina.AutoDependencyInjection.Attributes;
using TakasakiStudio.Lina.Common;
using TakasakiStudio.Lina.Database;
using TakasakiStudio.Lina.Database.Interfaces;
using TakasakiStudio.Lina.Database.Models;
using TakasakiStudio.Lina.Database.Repositories;
using TakasakiStudio.Lina.Utils.LoaderConfig;
var serviceCollection = new ServiceCollection();
var config = serviceCollection.AddLoaderConfig<IAppConfig>();
serviceCollection.AddAutoDependencyInjection<Program>();
serviceCollection.AddLinaDbContext<Program>((builder, assembly) =>
builder.UseMySql(config.DatabaseUrl, ServerVersion.AutoDetect(config.DatabaseUrl),
optionsBuilder => optionsBuilder.MigrationsAssembly(assembly)));
public interface IAppConfig
{
[Option(DefaultValue = "Server=localhost;Database=test;User Id=root;Password=root;")]
public string DatabaseUrl { get; }
}
public class User : BaseValidatedEntity<User, int>
{
public string Name { get; set; } = string.Empty;
protected override void SetupValidator(LinaAbstractValidator<ExampleModel> rules)
{
rules.RuleFor(x => x.Name).NotEmpty();
}
public static implicit operator User(UserViewModel viewModel)
{
return new User
{
Name = viewModel.Name
};
}
public static implicit operator UserViewModel(User user)
{
return new UserViewModel
{
Name = user.Name
};
}
}
public class UserConfiguration : IEntityTypeConfiguration<User>
{
public void Configure(EntityTypeBuilder<User> builder)
{
builder.ToTable("Users");
builder.HasKey(x => x.Id);
builder.Property(x => x.Name).IsRequired();
}
}
public record UserViewModel
{
public string Name { get; set; } = string.Empty;
}
public interface IUserRepository : IBaseRepository<User, int>
{
}
[Repository<IUserRepository>]
public class UserRepository : BaseRepository<User, int>, IUserRepository
{
public UserRepository(DbContext dbContext) : base(dbContext)
{
}
}
public interface IUserService
{
}
[Service<IUserService>]
public class UserService : IUserService
{
private readonly IUserRepository _userRepository;
public UserService(IUserRepository userRepository)
{
_userRepository = userRepository;
}
public async Task<UserViewModel?> Add(UserViewModel userViewModel)
{
User user = userViewModel;
await user.Validate();
await _userRepository.Add(user);
await _userRepository.Commit();
return user;
}
}
using Microsoft.AspNetCore.Mvc;
using TakasakiStudio.Lina.AspNet.Controllers;
[Controller]
public class AuthController() : PageController
{
[HttpGet]
public IActionResult Login()
{
return RenderComponent<LoginPage>(); // LoginPage is a Blazor component
}
}
using TakasakiStudio.Lina.AspNet.Workers;
public class MyWorker : AbstractHostedLifecycleService
{
public override Task StartingAsync(CancellationToken cancellationToken)
{
/*...*/
}
}
The entire project, except for the file is licensed under the . The file FileVersionProvider.cs was copied from Asp.NET Core under the MIT License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 1 NuGet packages that depend on TakasakiStudio.Lina.Database:
| Package | Downloads |
|---|---|
|
TakasakiStudio.Lina
A framework to simplify application creation by improving dependency injection, validation, config and database handling |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.0.0 | 350 | 11/13/2025 |
| 2.4.2 | 610 | 4/27/2025 |
| 2.4.1 | 217 | 4/26/2025 |
| 2.4.0 | 437 | 4/21/2025 |
| 2.3.7 | 345 | 3/14/2025 |
| 2.3.6 | 270 | 3/14/2025 |
| 2.3.5 | 430 | 2/24/2025 |
| 2.3.3 | 458 | 2/16/2025 |
| 2.3.2 | 238 | 2/16/2025 |
| 2.3.1 | 234 | 2/15/2025 |
| 2.3.0 | 280 | 11/18/2024 |
| 2.2.1 | 1,183 | 10/17/2024 |
| 2.2.0 | 445 | 10/9/2024 |
| 2.1.7 | 235 | 10/2/2024 |
| 2.1.6 | 641 | 8/30/2024 |
| 2.1.5 | 422 | 7/19/2024 |
| 2.1.4 | 255 | 6/27/2024 |
| 2.1.3 | 260 | 6/5/2024 |
| 2.1.2 | 343 | 5/15/2024 |
| 2.1.1 | 253 | 5/13/2024 |