• 不成功的MVC Repository模式,记录下来,后面看看原因在哪里(四) 上下文 及 model表


     1  public class WBIDbContext : DbContext
     2     {
     3         public DbSet<SysUserMdl> Users { get; set; }
     4         public DbSet<SysUserGroupMdl> UserGroups { get; set; }
     5         public DbSet<SysMenuModuleMdl> MenuModules { get; set; }
     6         public DbSet<SysMenuItemMdl> MenuItems { get; set; }
     7 
     8         public DbSet<VidCameraMdl> Cameras { get; set; }
     9 
    10         public DbSet<DevDevtypeMdl> DevType { get; set; }//增加设备表的读取
    11 
    12        // public DbSet<VidDiskRecorderMdl> VideoHosts { get; set; }
    13 
    14         public WBIDbContext()
    15             : base("DefaultConnection")
    16         {
    17         }
    18     }
     1 public class WBIContextFactory
     2     {
     3         private const string KEY_DB_CONTEXT = "WBIDbContext";
     4 
     5         public static WBIDbContext GetCurrentContext()
     6         {
     7             WBIDbContext dbContext =
     8                 CallContext.GetData(KEY_DB_CONTEXT) as WBIDbContext;
     9 
    10             if (dbContext == null)
    11             {
    12                 dbContext = new WBIDbContext();
    13                 CallContext.SetData(KEY_DB_CONTEXT, dbContext);
    14             }
    15 
    16             return dbContext;
    17         }
    18     }
     1  //设备类型
     2     [Table("t_dev_devtype")]
     3     public class DevDevtypeMdl  
     4     {
     5         [Key]
     6         [Display(Name="设备编号")]
     7         public string devid { get; set; }
     8         [Display(Name = "设备编码")]
     9         public string devtype { get; set; }
    10         [Display(Name = "名称描述")]
    11         public string devdesc { get; set; }
    12         [Display(Name = "排序")]
    13         public string devorder { get; set; }
    14         [Display(Name = "设备备注")]
    15         public string devmemo { get; set; }
    16     }
  • 相关阅读:
    第四季-专题8-Linux系统调用
    第四季-专题7-Linux内核链表
    Python3 运算符
    Python2和Python3有什么区别?
    python常见的PEP8规范
    机器码和字节码
    域名是什么?为什么域名是www开头?
    selenium自动化登录qq邮箱
    xpath+selenium工具爬取腾讯招聘全球岗位需求
    ArrayList
  • 原文地址:https://www.cnblogs.com/minglilee2012/p/4043803.html
Copyright © 2020-2023  润新知