public string? Name { get; set; } public int Age { get; set; } public int CompanyId { get; set; } public Company? Company { get; set; } } public class ApplicationContext : DbContext { public DbSet Users { get; set; } = null!; public DbSet Companies { get; set; } = null!; protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=helloappdb; Trusted_Connection=True;"); }} Muntazam SQL so'rovlari bilan bir qatorda, Entity Framework Core ham ma'lumotlar bazasida yaratilgan saqlangan funktsiyalarni bajarishga imkon beradi. Misol sifatida MS SQL Server ma'lumotlar bazasidan foydalanib, C# ilovasida saqlangan funksiyani chaqirishni ko'rib chiqamiz. Bizning ma'lumotlar bazamiz quyidagi ma'lumotlar konteksti va ob'ektlari bilan tavsiflansin: using Microsoft.EntityFrameworkCore; { public int Id { get; set; } public string? Name { get; set; } public List Users { get; set; } = new();} public class User{ public int Id { get; set; } public string? Name { get; set; } public int Age { get; set; } public int CompanyId { get; set; } public Company? Company { get; set; }} public class ApplicationContext : DbContext { public DbSet Users { get; set; } = null!;
Do'stlaringiz bilan baham: |