DataContext.cs 1.02 KB
using FreeSql;
using HHECS.DAQShared.Models;

namespace HHECS.DAQShared.DataAccess
{
    /// <summary>
    /// 数据库上下文
    /// </summary>
    /// <remarks>参考文档:<a href="https://freesql.net/guide/db-context.html">https://freesql.net/guide/db-context.html</a></remarks>
    public class DataContext : DbContext
    {
        private readonly IFreeSql _freeSql;

        public DataContext(IFreeSql freeSql)
        {
            _freeSql = freeSql;
        }

        public DbSet<Equipment> Equipment { get; set; } = null!;

        public DbSet<EquipmentProperty> EquipmentProperties { get; set; } = null!;

        public DbSet<EquipmentDataRecord> EquipmentDataRecord { get; set; } = null!;

        public DbSet<EquipmentAlarmRecord> EquipmentAlarmRecords { get; set; } = null!;

        public DbSet<EquipmentStatusRecord> EquipmentStatusRecords { get; set; } = null!;

        protected override void OnConfiguring(DbContextOptionsBuilder options)
        {
            options.UseFreeSql(_freeSql);
        }
    }
}