Equipment.cs
1.83 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using DataAcquisition.Common.Enums;
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using IndexAttribute = Microsoft.EntityFrameworkCore.IndexAttribute;
namespace DataAcquisition.Models
{
[Comment("设备表")]
[Table("Equipment")]
[Index(nameof(Code), IsUnique = true)]
public class Equipment
{
public Equipment()
{
EquipmentProperties = new List<EquipmentProperty>();
}
[Key]
[Comment("设备Id")]
public int Id { get; set; }
[Comment("通讯方式")]
[ForeignKey(nameof(CommunicationConfig))]
public int? CommunicationId { get; set; }
public virtual CommunicationConfig? CommunicationConfig { get; set; }
[Comment("设备编号")]
public string Code { get; set; } = null!;
[Comment("设备名称")]
public string Name { get; set; } = null!;
[Comment("设备类型")]
public EquipmentTypeConst EquipmentType { get; set; }
[Comment("是否启用")]
public bool Enable { get; set; }
[Comment("区域")]
public int Area { get; set; }
[Comment("创建时间")]
public DateTime? CreateTime { get; set; } = DateTime.Now;
[Comment("更新时间")]
public DateTime? UpdateTime { get; set; } = null!;
[Comment("备注")]
public string? Remark { get; set; }
public virtual IList<EquipmentProperty> EquipmentProperties { get; set; }
[Comment("设备云平台SN")]
public string? EquipmentSN { get; set; }
[Comment("仓库编号")]
public string? WarehouseCode { get; set; }
public virtual EquipmentProperty this[string key] => EquipmentProperties.Where(x => x.Code.Equals(key)).First();
}
}