using EC.Entity.CameraInfo; using Microsoft.EntityFrameworkCore; using System.Collections.Generic; using System.Threading.Tasks; #nullable disable namespace EC.Service.CameraInfo { public class NvrInfoContext : BaseDbContext { public NvrInfoContext() { } protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity(entity => { entity.HasKey(e => e.NvrId); entity.ToTable("NvrInfo"); entity.Property(e => e.NvrId).HasColumnName("NvrID"); entity.Property(e => e.NvrAddr).HasColumnType("VARCHAR (100)"); entity.Property(e => e.NvrEnable) .IsRequired() .HasColumnType("VARCHAR (2)"); entity.Property(e => e.NvrIp) .IsRequired() .HasColumnType("VARCHAR (18)") .HasColumnName("NvrIP"); entity.Property(e => e.NvrName) .IsRequired() .HasColumnType("VARCHAR (30)"); entity.Property(e => e.NvrType).HasColumnType("VARCHAR (20)"); entity.Property(e => e.UserName).HasColumnType("VARCHAR (20)"); entity.Property(e => e.UserPwd).HasColumnType("VARCHAR (20)"); }); OnModelCreatingPartial(modelBuilder); } #region Operate public List GetNvrDeviceList() { List list = new() { "海康", "大华", "宇视", "深广", "泰杰", "其它" }; return list; } public async Task> GetNvrNameListAsync() { List list = new(); List infos = await GetListAsync(); foreach (NvrInfo info in infos) { if (!list.Contains(info.NvrName)) { list.Add(info.NvrName); } } return list; } #endregion Operate } }