- Регистрация
- 1 Мар 2015
- Сообщения
- 1,481
- Баллы
- 155
Here's what I’m using so far:
Program.cs
builder.Services.AddSwaggerGen();
builder.Services.AddDbContext<IngatlanContext>(options => options.UseSqlite(builder.Configuration.GetConnectionString("DefaultConnection")));
var app = builder.Build();
===
Context.cs:
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!;
}
Dto:
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; }
}
How to
Kategoria (1) - Ingatlan (N)
N: [ForeignKey("KategoriaId")] public Kategoria? Kategoria { get; set; }
1: [JsonIgnore] public List? Ingatlanok { get; set; }
Program.cs
builder.Services.AddSwaggerGen();
builder.Services.AddDbContext<IngatlanContext>(options => options.UseSqlite(builder.Configuration.GetConnectionString("DefaultConnection")));
var app = builder.Build();
===
Context.cs:
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!;
}
Dto:
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; }
}
How to
Kategoria (1) - Ingatlan (N)
N: [ForeignKey("KategoriaId")] public Kategoria? Kategoria { get; set; }
1: [JsonIgnore] public List? Ingatlanok { get; set; }