[英]How to keep values in sync between an XML configuration file and a database table?
我正在按層次結構分層構建。 舉個例子。
Category 7
Objective 7.1 [GeneralExpectation='']
A [Expectation='']
B [Expectation='']
C [Expectation='']
Objective 7.2 [GeneralExpectation='']
A [Expectation='']
B [Expectation='']
Objective 7.3 [GeneralExpectation='']
A [Expectation='']
Category 8
...
我想將這些信息存儲在xml文件而不是數據庫中會很方便。
<Levels>
<Level Id=7>
<Categories>
<Category Id=1 Name="Numbers, Operations, and Quantitative Reasoning" Expectation="The student will demonstrate an understanding of numbers, operations, and quantitative reasoning.">
<Objective Id="7.1" Name="Number, operation, and quantitative reasoning." GeneralExpectation="The student represents and uses numbers in a variety of equivalent forms. The student is expected to">
<SubObjective Id="A" Expectation="compare and order integers and positive rational numbers; Supporting Standard" />
<SubObjective Id="B" Expectation="convert between fractions, decimals, whole numbers, and percents mentally, on paper, [or with a calculator]; and Readiness Standard" />
</Objective>
</Category>
<Category Id=2 Name="Patterns, Relationships, and Algebraic Reasoning" Expectation="The student will demonstrate an understanding of patterns, relationships, and algebraic reasoning.">
</Category>
</Categories>
</Level>
</Levels>
我這樣做是因為我需要在WPF中的TreeView
控件中訪問此信息。 但是同時,我的SQL數據庫中有一個表,該表需要存儲用戶正在使用的Level目標: 7.1A, 7.1B, 7.1C, 7.2A
。
這是一個好習慣嗎? 還是我沒有保留兩個數據之間的關系。
@DarfZon,我將數據保留為一種格式(如果您的其他數據也是關系型的,我的建議是使用SQL Server)。 您可以使用SQL Server強大的XML語法和FOR XML子句以分層格式檢索SQL Server中的關系數據。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.