简体   繁体   English

在 C# 和 sql 中管理应用程序用户选项的最佳方法是什么?

[英]what is the best way to manage application user options in C# and sql?

My application has dozens of ComboBoxes filled with lists of values.我的应用程序有几十个 ComboBoxes 填充了值列表。

I wonder what is the best way to store these values in the DB since the user can add/remove:我想知道将这些值存储在数据库中的最佳方法是什么,因为用户可以添加/删除:

  1. Store in XML in Sql Server?存储在 Sql 服务器的 XML 中?
  2. Store in a text file on the server?存储在服务器上的文本文件中?
  3. any best practice?任何最佳做法?

Thanks John谢谢约翰

I would keep track of them in a table on SQL server.我会在 SQL 服务器上的表格中跟踪它们。 If a user can define each field, then you simply need a table with a field name, value, and userid.如果用户可以定义每个字段,那么您只需要一个包含字段名称、值和用户 ID 的表。 Then you can extrapolate all of it from there.然后你可以从那里推断出所有这些。

Of course, you would want to use a key of some kind linked to a table that defines each type of field possible, if needed.当然,如果需要,您可能希望使用链接到表的某种键,该表定义了可能的每种类型的字段。

One row per key/value (combobox) should do the trick.每个键/值(组合框)一行应该可以解决问题。

Another option to consider is to serialize your form in a json string that you'll store in a table in the SQL server DB.另一个要考虑的选项是将表单序列化为 json 字符串,您将存储在 SQL 服务器数据库的表中。 That way, you'll only have one entry per user to read.这样,每个用户只能阅读一个条目。 Then, you can deserialize the json string in an object that retains the properties of each control.然后,您可以在保留每个控件的属性的 object 中反序列化 json 字符串。

The big advantage of doing it this way is that if your form changes (and changes do happen.) you won't have to modify the data layer (ie. table definition + query).这样做的最大好处是,如果您的表单发生更改(并且确实发生了更改。)您将不必修改数据层(即表定义+查询)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在C#中保存每个用户选项的最佳方法 - Best way to save per user options in C# 在C#Windows窗体应用程序中存储/读取多个用户设置的最佳方法是什么? - What is the best way to store/read multiple user settings in a C# Windows Form Application? 在C#应用程序中使用LINQ to SQL的最佳实践方法是什么? [设计模式] - What is the best-practice way to use LINQ to SQL in a C# application? [Design-pattern] 在C#Web应用程序中实现通知的最佳方法是什么? - What is the best way to implement notification in a C# web application? 在C#中设计全屏应用程序的最佳方法是什么? - What's the best way to design a full screen application in C#? 存储/设置C#应用程序配置设置的最佳方法是什么? - What is the best way to store/set configuration settings for a C# application? 在C#中捕获应用程序窗口的最佳方法是什么? - What is the best way to capture an application window in C#? 在C#中存储用户特定数据的最佳方法是什么? - What is the best way to to store user specific data in C#? 让用户在 C# 中选择子目录的最佳方法是什么? - What's the best way to let a user pick a subdirectory in C#? 允许用户在C#中浏览文件的最佳方法是什么? - What's the best way to allow a user to browse for a file in C#?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM