DataContext.cs
1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using FreeSql;
using HHECS.DAQHandle.Models;
using HHECS.EquipmentModel;
namespace HHECS.DAQHandle.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<EquipmentType> EquipmentType { get; set; } = null!;
public DbSet<EquipmentTypePropTemplate> EquipmentTypePropTemplate { get; set; } = null!;
public DbSet<EquipmentProp> EquipmentProp { 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);
}
}
}