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 (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);
|
var ret = DbContextManager.Create<Dict>().Save(p);
|
||||||
if (ret) CacheCleanUtility.ClearCache(dictIds: new List<string>());
|
if (ret) CacheCleanUtility.ClearCache(dictIds: new List<string>());
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -38,6 +38,7 @@ namespace Bootstrap.DataAccess
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static bool Save(Group p)
|
public static bool Save(Group p)
|
||||||
{
|
{
|
||||||
|
if (p.Id == string.Empty) p.Id = null;
|
||||||
var ret = DbContextManager.Create<Group>().Save(p);
|
var ret = DbContextManager.Create<Group>().Save(p);
|
||||||
if (ret) CacheCleanUtility.ClearCache(groupIds: string.IsNullOrEmpty(p.Id) ? new List<string>() : new List<string>() { p.Id });
|
if (ret) CacheCleanUtility.ClearCache(groupIds: string.IsNullOrEmpty(p.Id) ? new List<string>() : new List<string>() { p.Id });
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -24,6 +24,7 @@ namespace Bootstrap.DataAccess
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static bool Save(Log log)
|
public static bool Save(Log log)
|
||||||
{
|
{
|
||||||
|
if (log.Id == string.Empty) log.Id = null;
|
||||||
log.LogTime = DateTime.Now;
|
log.LogTime = DateTime.Now;
|
||||||
return DbContextManager.Create<Log>().Save(log);
|
return DbContextManager.Create<Log>().Save(log);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,11 @@ namespace Bootstrap.DataAccess
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="userName"></param>
|
/// <param name="userName"></param>
|
||||||
/// <returns></returns>
|
/// <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>
|
/// <summary>
|
||||||
/// 查询指定页码登录日志
|
/// 查询指定页码登录日志
|
||||||
|
|
|
@ -45,6 +45,7 @@ namespace Bootstrap.DataAccess
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (p.Id == string.Empty) p.Id = null;
|
||||||
var ret = DbContextManager.Create<Menu>().Save(p);
|
var ret = DbContextManager.Create<Menu>().Save(p);
|
||||||
if (ret) CacheCleanUtility.ClearCache(menuIds: string.IsNullOrEmpty(p.Id) ? new List<string>() : new List<string>() { p.Id });
|
if (ret) CacheCleanUtility.ClearCache(menuIds: string.IsNullOrEmpty(p.Id) ? new List<string>() : new List<string>() { p.Id });
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -14,6 +14,7 @@ namespace Bootstrap.DataAccess
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static bool Save(ResetUser user)
|
public static bool Save(ResetUser user)
|
||||||
{
|
{
|
||||||
|
if (user.Id == string.Empty) user.Id = null;
|
||||||
user.ResetTime = DateTime.Now;
|
user.ResetTime = DateTime.Now;
|
||||||
return DbContextManager.Create<ResetUser>().Save(user);
|
return DbContextManager.Create<ResetUser>().Save(user);
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,6 +68,7 @@ namespace Bootstrap.DataAccess
|
||||||
var roles = new string[] { "Administrators", "Default" };
|
var roles = new string[] { "Administrators", "Default" };
|
||||||
var rs = Retrieves().Where(r => roles.Any(rl => rl.Equals(r.RoleName, StringComparison.OrdinalIgnoreCase)));
|
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 (rs.Any(r => r.Id == p.Id)) return true;
|
||||||
|
if (p.Id == string.Empty) p.Id = null;
|
||||||
var ret = DbContextManager.Create<Role>().Save(p);
|
var ret = DbContextManager.Create<Role>().Save(p);
|
||||||
if (ret) CacheCleanUtility.ClearCache(roleIds: string.IsNullOrEmpty(p.Id) ? new List<string>() : new List<string> { p.Id });
|
if (ret) CacheCleanUtility.ClearCache(roleIds: string.IsNullOrEmpty(p.Id) ? new List<string>() : new List<string> { p.Id });
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Reference in New Issue