86 lines
3.0 KiB
C#
86 lines
3.0 KiB
C#
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; }
|
||
}
|
||
}
|