Добавил lazyLoading

parent daab1daa
......@@ -9,7 +9,7 @@ namespace Payment.WebApi.Controllers;
[ApiController]
[Route("Users/[action]")]
[Produces("applications/json")]
[Produces("application/json")]
public class UserController : Controller
{
private readonly IUserRepository _userRepository;
......
......@@ -12,6 +12,11 @@ public class PaymentDbContext : DbContext
{
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseLazyLoadingProxies();
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
......
......@@ -8,7 +8,7 @@ public class User
public string? MiddleName { get; set; }
public string Email { get; set; }
public int Age { get; set; }
public List<UserBalance> Balances { get; set; }
public virtual List<UserBalance> Balances { get; set; }
public bool IsActive { get; set; }
public User()
......
......@@ -6,5 +6,5 @@ public class UserBalance
public decimal Amount { get; set; }
public string Currency { get; set; }
public int UserId { get; set; }
public User User { get; set; }
public virtual User User { get; set; }
}
\ No newline at end of file
......@@ -11,6 +11,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="6.0.7" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="6.0.5" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.4.0" />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment