refactor(PetaPoco): 字符串类型的主键为String.Empty保存失败
#Issue link https://github.com/CollaboratingPlatypus/PetaPoco/issues/538
This commit is contained in:
parent
0391a20b57
commit
82417b68af
|
@ -63,6 +63,7 @@ namespace Bootstrap.DataAccess
|
|||
{
|
||||
if (RetrieveSystemModel() && RetrieveProtectedDicts().Any(m => m.Id == p.Id)) return true;
|
||||
|
||||
if (p.Id == string.Empty) p.Id = null;
|
||||
var ret = DbContextManager.Create<Dict>().Save(p);
|
||||
if (ret) CacheCleanUtility.ClearCache(dictIds: new List<string>());
|
||||
return ret;
|
||||
|
|
|
@ -38,6 +38,7 @@ namespace Bootstrap.DataAccess
|
|||
/// <returns></returns>
|
||||
public static bool Save(Group p)
|
||||
{
|
||||
if (p.Id == string.Empty) p.Id = null;
|
||||
var ret = DbContextManager.Create<Group>().Save(p);
|
||||
if (ret) CacheCleanUtility.ClearCache(groupIds: string.IsNullOrEmpty(p.Id) ? new List<string>() : new List<string>() { p.Id });
|
||||
return ret;
|
||||
|
|
|
@ -24,6 +24,7 @@ namespace Bootstrap.DataAccess
|
|||
/// <returns></returns>
|
||||
public static bool Save(Log log)
|
||||
{
|
||||
if (log.Id == string.Empty) log.Id = null;
|
||||
log.LogTime = DateTime.Now;
|
||||
return DbContextManager.Create<Log>().Save(log);
|
||||
}
|
||||
|
|
|
@ -16,7 +16,11 @@ namespace Bootstrap.DataAccess
|
|||
/// </summary>
|
||||
/// <param name="userName"></param>
|
||||
/// <returns></returns>
|
||||
public static bool Log(LoginUser user) => DbContextManager.Create<LoginUser>().Log(user);
|
||||
public static bool Log(LoginUser user)
|
||||
{
|
||||
if (user.Id == string.Empty) user.Id = null;
|
||||
return DbContextManager.Create<LoginUser>().Log(user);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询指定页码登录日志
|
||||
|
|
|
@ -45,6 +45,7 @@ namespace Bootstrap.DataAccess
|
|||
}
|
||||
}
|
||||
}
|
||||
if (p.Id == string.Empty) p.Id = null;
|
||||
var ret = DbContextManager.Create<Menu>().Save(p);
|
||||
if (ret) CacheCleanUtility.ClearCache(menuIds: string.IsNullOrEmpty(p.Id) ? new List<string>() : new List<string>() { p.Id });
|
||||
return ret;
|
||||
|
|
|
@ -14,6 +14,7 @@ namespace Bootstrap.DataAccess
|
|||
/// <returns></returns>
|
||||
public static bool Save(ResetUser user)
|
||||
{
|
||||
if (user.Id == string.Empty) user.Id = null;
|
||||
user.ResetTime = DateTime.Now;
|
||||
return DbContextManager.Create<ResetUser>().Save(user);
|
||||
}
|
||||
|
|
|
@ -68,6 +68,7 @@ namespace Bootstrap.DataAccess
|
|||
var roles = new string[] { "Administrators", "Default" };
|
||||
var rs = Retrieves().Where(r => roles.Any(rl => rl.Equals(r.RoleName, StringComparison.OrdinalIgnoreCase)));
|
||||
if (rs.Any(r => r.Id == p.Id)) return true;
|
||||
if (p.Id == string.Empty) p.Id = null;
|
||||
var ret = DbContextManager.Create<Role>().Save(p);
|
||||
if (ret) CacheCleanUtility.ClearCache(roleIds: string.IsNullOrEmpty(p.Id) ? new List<string>() : new List<string> { p.Id });
|
||||
return ret;
|
||||
|
|
Loading…
Reference in New Issue