79619726

Date: 2025-05-13 13:18:25
Score: 0.5
Natty:
Report link

https://i.sstatic.net/BhqQFfzu.png creation

https://i.sstatic.net/8wnINKTK.png models

https://i.sstatic.net/CQYoXJrk.png navigation property

https://i.sstatic.net/0kJXyftC.png dbset making

https://i.sstatic.net/H3h5ntBO.png scaffolded itmes creation

https://i.sstatic.net/GkqwZUQE.png dto creation

https://i.sstatic.net/5Fxy0sHO.png put endpoint changes

here is a code for that:

builder.Services.AddSwaggerGen();

builder.Services.AddDbContext<IngatlanContext>(options =>
    options.UseSqlite(builder.Configuration.GetConnectionString("DefaultConnection")));

var app = builder.Build();

--------------------------------
public class IngatlanContext : DbContext
{
    public IngatlanContext(DbContextOptions<IngatlanContext> options) : base(options)
    {

    }
    public DbSet<Ingatlan> Ingatlanok { get; set; } = null!;
    public DbSet<Kategoria> Kategoriak { get; set; } = null!;
}

--------------------------------
public class IngatlanGetDto
{
    public int Id { get; set; }
    public string? Leiras { get; set; }
    public DateTime HirdetesKezdete { get; set; }
    public DateTime HirdetesVege { get; set; }
    public int Ar { get; set; }
    public bool Hitelkepes { get; set; }
    public string? KategoriaNeve { get; set; }
}

--------------------------------
Kategoria (1) - Ingatlan (N)
N: 
[ForeignKey("KategoriaId")]
public Kategoria? Kategoria { get; set; }
1:
[JsonIgnore]
public List<Ingatlan>? Ingatlanok { get; set; }
Reasons:
  • Probably link only (1):
  • Long answer (-1):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: orbanviktor