多分このような何かがC#側であなたのために働くでしょう。 SQL側で
public class Option
{
public string Name { get; set; }
/// <summary>
/// Used to treat the sub options as seperate properties rather than
/// options for this property.
/// </summary>
public bool IsCategory { get; set; }
/// <summary>
/// Lists of available options for this property, or sub properties
/// for this property if `IsCategory` is true.
/// </summary>
public List<Option> Options { get; set; }
/// <summary>
/// If `IsCategory` is false, indicates the selected option for this property.
/// </summary>
public Option SelectedOption { get; set; }
public Option(string name, bool isCategory)
{
Name = name;
IsCategory = isCategory;
Options = new List<Options>();
}
}
public void Example()
{
Option pipes = new Option("Pipes", true);
Option material = new Option("Material", false);
Option size= new Option("Size", false);
Option blackSteel = new Option("Black Steel", true);
Option stainlessSteel = new Option("Stainless Steel", true);
Option schedule = new Option("Schedule", false);
schedule.Options.Add(new Option("10", false));
schedule.Options.Add(new Option("20", false));
schedule.Options.Add(new Option("40", false));
schedule.Options.Add(new Option("80", false));
blackSteel.Options.Add(schedule);
stainlessSteel.Options.Add(schedule);
material.Options.Add(blackSteel);
material.Options.Add(stainlessSteel);
pipes.Options.Add(material);
pipes.Options.Add(size);
}
、あなたは次のようにテーブルを作り、各オプションに一意のインデックスを与えることによって、これらのオプションを定義できます。
+---------+-----------------+---------------------+------------------+
| ID<INT> | NAME<VARCHAR> | ISCATEGORY<BOOLEAN> | OPTIONS<VARCHAR> |
+---------+-----------------+---------------------+------------------+
| 0 | Pipes | true | 1,2 |
| 1 | Material | false | 3,4 |
| 2 | Size | false | |
| 3 | Black Steel | true | 5 |
| 4 | Stainless Steel | true | 5 |
| 5 | Schedule | false | 6,7,8,9 |
| 6 | 10 | false | |
| 7 | 20 | false | |
| 8 | 30 | false | |
| 9 | 40 | false | |
+---------+-----------------+---------------------+------------------+
まあこれはどの*リレーショナル日付ベース*の典型的な構造です。あなたの問題は何ですか?私はテーブル/タイプ 'パイプ'、 'スプリンクラー'、 '物質'、 'スケジュール'などを見ています。フィールド/プロパティ 'Material'、' Size'、スケジュールなど」 – InBetween
問題SQLサーバーにテーブルを作成しようとしましたが、テーブルを正しく構築してもテーブル間の関係を作成できませんでした – Tima