Exemple #1
0
 /// <summary>
 /// 根据主键Id获取一个用户
 /// </summary>
 /// <param name="id">主键Id</param>
 /// <param name="connectionString">链接字符串</param>
 /// <returns></returns>
 public User RetriveOneEntityById(int id, string connectionString = null)
 {
     using (LightContext context = MySQLDataBaseConfig.CreateContext(connectionString))
     {
         return(context.Find <User>(id));
     }
 }
Exemple #2
0
 /// <summary>
 /// 根据主键Id删除一个用户
 /// </summary>
 /// <param name="id">主键Id</param>
 /// <param name="connectionString">链接字符串</param>
 /// <returns></returns>
 public bool DeleteEntityById(int id, string connectionString = null)
 {
     using (LightContext context = MySQLDataBaseConfig.CreateContext(connectionString))
     {
         context.User.Remove(context.Find <User>(id));
         return(context.SaveChanges() > 0);
     }
 }