refactor: 根据最新的PetaPoco移除字符串主键设置为Null
This commit is contained in:
parent
62b00389f9
commit
bbad37ce6e
|
@ -18,13 +18,7 @@ namespace Bootstrap.DataAccess
|
|||
/// <returns></returns>
|
||||
public static IDatabase Create(string connectionName = null, bool keepAlive = false)
|
||||
{
|
||||
if (Mappers.GetMapper(typeof(Exceptions), null) == null)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
if (Mappers.GetMapper(typeof(Exceptions), null) == null) Mappers.Register(typeof(Exceptions).Assembly, new BootstrapDataAccessConventionMapper());
|
||||
}
|
||||
}
|
||||
if (Mappers.GetMapper(typeof(Exceptions), null) == null) Mappers.Register(typeof(Exceptions).Assembly, new BootstrapDataAccessConventionMapper());
|
||||
var db = Longbow.Data.DbManager.Create(connectionName, keepAlive);
|
||||
db.ExceptionThrown += (sender, args) => args.Exception.Log(new NameValueCollection() { ["LastCmd"] = db.LastCommand });
|
||||
return db;
|
||||
|
|
|
@ -60,7 +60,6 @@ namespace Bootstrap.DataAccess
|
|||
{
|
||||
if (RetrieveSystemModel() && !string.IsNullOrEmpty(p.Id) && 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;
|
||||
|
|
|
@ -51,7 +51,6 @@ 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;
|
||||
|
|
|
@ -34,7 +34,6 @@ 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);
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@ namespace Bootstrap.DataAccess
|
|||
/// <returns></returns>
|
||||
public static bool Log(LoginUser user)
|
||||
{
|
||||
if (user.Id == string.Empty) user.Id = null;
|
||||
if (string.IsNullOrEmpty(user.UserName)) user.UserName = user.Ip;
|
||||
return DbContextManager.Create<LoginUser>().Log(user);
|
||||
}
|
||||
|
|
|
@ -32,7 +32,6 @@ namespace Bootstrap.DataAccess
|
|||
// 不允许保存系统菜单与前台演示系统的默认菜单
|
||||
if (DictHelper.RetrieveSystemModel() && (p.Category == "0" || p.Application == "2")) return true;
|
||||
|
||||
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;
|
||||
|
|
|
@ -54,10 +54,6 @@ namespace Bootstrap.DataAccess
|
|||
/// </summary>
|
||||
/// <param name="msg"></param>
|
||||
/// <returns></returns>
|
||||
public static bool Save(Message msg)
|
||||
{
|
||||
if (string.IsNullOrEmpty(msg.Id)) msg.Id = null;
|
||||
return DbContextManager.Create<Message>().Save(msg);
|
||||
}
|
||||
public static bool Save(Message msg) => DbContextManager.Create<Message>().Save(msg);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@ 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);
|
||||
}
|
||||
|
|
|
@ -78,7 +78,6 @@ 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;
|
||||
|
|
|
@ -25,10 +25,6 @@ namespace Bootstrap.DataAccess
|
|||
/// </summary>
|
||||
/// <param name="task"></param>
|
||||
/// <returns></returns>
|
||||
public static bool Save(Task task)
|
||||
{
|
||||
if (string.IsNullOrEmpty(task.Id)) task.Id = null;
|
||||
return DbContextManager.Create<Task>().Save(task);
|
||||
}
|
||||
public static bool Save(Task task) => DbContextManager.Create<Task>().Save(task);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,6 @@ namespace Bootstrap.DataAccess
|
|||
v.DisplayName = user.DisplayName;
|
||||
DbContextManager.Create<Trace>().Save(new Trace
|
||||
{
|
||||
Id = null,
|
||||
Ip = v.Ip,
|
||||
RequestUrl = v.RequestUrl,
|
||||
LogTime = v.LastAccessTime,
|
||||
|
|
Loading…
Reference in New Issue