PIbd-21_MasenkinMS_Coursewo.../Hospital/HospitalDatabaseImplement/HospitalDatabase.cs
2024-04-25 02:00:30 +04:00

86 lines
3.0 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using HospitalDatabaseImplement.Models;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
namespace HospitalDatabaseImplement
{
/// <summary>
/// Класс для взаимодействия с базой данных
/// </summary>
public class HospitalDatabase : DbContext
{
/// <summary>
/// Параметры подключения к базе данных
/// </summary>
private string _dbConnectionString = @"Data Source=FACTORINO\SQLEXPRESS;Initial Catalog=HospitalDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True";
/// <summary>
/// Подключение к базе данных
/// </summary>
/// <param name="optionsBuilder"></param>
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (optionsBuilder.IsConfigured == false)
{
optionsBuilder.UseSqlServer(_dbConnectionString);
}
base.OnConfiguring(optionsBuilder);
}
/// <summary>
/// Таблица "Доктора"
/// </summary>
public virtual DbSet<Doctor> Doctors { get; set; }
/// <summary>
/// Таблица "Пациенты"
/// </summary>
public virtual DbSet<Patient> Patients { get; set; }
/// <summary>
/// Таблица "Рецепты"
/// </summary>
public virtual DbSet<Recipe> Recipes { get; set; }
/// <summary>
/// Таблица "Болезни"
/// </summary>
public virtual DbSet<Disease> Diseases { get; set; }
/// <summary>
/// Таблица "Процедуры"
/// </summary>
public virtual DbSet<Procedure> Procedures { get; set; }
/// <summary>
/// Таблица "Лекарства"
/// </summary>
public virtual DbSet<Medicine> Medicines { get; set; }
/// <summary>
/// Таблица связи для сущностей "Пациент" и "Рецепт"
/// </summary>
public virtual DbSet<PatientRecipe> PatientRecipes { get; set; }
/// <summary>
/// Таблица связи для сущностей "Пациент" и "Процедура"
/// </summary>
public virtual DbSet<PatientProcedure> PatientProcedures { get; set; }
/// <summary>
/// Таблица связи для сущностей "Рецепт" и "Лекарство"
/// </summary>
public virtual DbSet<RecipeMedicine> RecipeMedicines { get; set; }
/// <summary>
/// Таблица связи для сущностей "Процедура" и "Лекарство"
/// </summary>
public virtual DbSet<ProcedureMedicine> ProcedureMedicines { get; set; }
}
}