/// <summary> /// 设置配置值 /// </summary> /// <param name="conf"></param> /// <param name="tenantId"></param> /// <param name="value"></param> public static void SetConfig(Enums.Configs conf, int tenantId, object value) { string val; if (value == null) { val = ""; } else { val = value.ToString(); } var sqlwhere = "Sys_Config.ConfigName=@name AND Sys_Config.TenantId=@tenantId"; var config = DataAccess.GetList <Models.SysConfig>(sqlwhere, new { name = conf.ToString(), tenantId }).FirstOrDefault(); if (config == null) { config = new Models.SysConfig() { ConfigCode = conf.ToString(), ConfigName = conf.ToString(), ConfigValue = val, TenantId = tenantId }; DataAccess.AddEntity(config); } else { config.ConfigValue = val; DataAccess.UpdateEntity(config); } }
public static T GetConfig <T>(Enums.Configs conf, int tenantId) { var configName = conf.ToString(); var configValue = GetConfig(configName, tenantId); var value = (T)Convert.ChangeType(configValue, typeof(T)); return(value); }