【问题标题】:How to keep values in sync between an XML configuration file and a database table?如何在 XML 配置文件和数据库表之间保持值同步?
【发布时间】:2012-12-10 14:47:06
【问题描述】:

我在层次中以分层方式构建。举个例子。

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 数据库中有一个表需要存储用户正在使用的级别目标:7.1A, 7.1B, 7.1C, 7.2A

这是一个好习惯吗?或者我没有保留这两个数据之间的关系。

【问题讨论】:

    标签: c# sql-server xml sql-server-2008 hierarchical-data


    【解决方案1】:

    @DarfZon,我会将数据保留为一种格式(如果您的其他数据也是关系数据,我的建议是 SQL Server)。您可以使用 SQL Server 强大的 XML 语法和FOR XML 子句以分层格式检索 SQL Server 中的关系数据。

    【讨论】:

      猜你喜欢
      • 2021-07-28
      • 2019-01-09
      • 1970-01-01
      • 2017-12-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多