c# - Individual user settings in ASP.Net Core 3.1
问题描述
I need to have bunch of settings for each user. Theese settings are same for all the users but every user can change their values. I'm looking for a good approach to create such an infrastructure. My best guess for now is table with all the settings in DB and a table with SettingId UserId and value. Not sure this is the best way tho.
解决方案
在 .net core 中,您还可以使用 appsettings.json 来存储如下配置:
{
"Users": {
"Arun": {
"Id": "ArunId",
"Name": "ArunName"
},
"Santa": {
"Id": "SantaId",
"Name": "SantaName"
}
}
}
您可以在 IConfiguration 接口的帮助下直接将它们转换为强类型对象,如下所示:
_configuration.GetSection("用户")
推荐阅读
- apache-spark - 几天后,Spark 流作业将状态从 RUNNING 更改为 ACCEPTED
- tsql - 使用 cte 和变量来更新 SQL 中的日期
- php - 更新 WordPress 4.9.6 后 Gzip 压缩不起作用
- c# - Linq 查询添加到我的数据库 c# ERROR
- ios - SQLite 和 Objective C - WHERE LIKE 语句错误
- php - PHP:不能在数组中使用空数组元素
- jsf - 如何在数据更改时刷新 ViewScoped(Omnifaces) 页面?
- java - 如何将休眠中的查询结果显示到引导程序中的表?
- linux - OIFS=$IFS是什么意思;IFS="|"; 在 bash 脚本中
- .net - 上下文等待随机失败/连续两次调用相同的“等待方法”