0

定期的に参照する必要のある静的な読み取り専用の情報テーブルがあります。重要なのは、このデータは関連しており、他の関連するプロパティのいずれかをインデックスとして使用して、任意のプロパティを取得できる必要があるということです...

1つまたは2つのケースでは、プロパティの1つが行間で重複する可能性がありますが、これはめったに発生しません...(例のORDR値を参照)

例:

formtypex | objectcode | table | description
  149          23         OQUT     Quotation
  139          17         ORDR     Order
  140          18         ORDR     Especial Order

望ましい使用法は次のようになります。

//having one property recover another property the easiest and fastest way possible
string exampleformtypex="149";

string objectcodex=relations.FromFormtypex(exampleformtypex).ObjectCode;

//or a shorter way:
string objectcodex=relations.Find(exampleformtypex, FindMode.FormTypex).ObjectCode;

//or
string objectcodex=relations.Find(exampleformtypex, FindMode.FormTypex, ResultMode.ObjectCode);

//or better
string objectcodex=relations[FindMode.FormTypex, exampleformtypex].ObjectCode;

//or if you can illustrate me with a better aproach
...

これを実装するためのクラス/esの定義とメソッドはどうですか?

4

1 に答える 1

1

小さなデータセットを考えると、すべての値を保持するクラス (または構造体) を作成し、すべてをメモリにロードするのが最善の策です。

public class Relations
{
  public int formtypex;
  public int objectcode;
  public string table;
  public string description;

}

次に、それをリストに入れ、li​​nq を使用してクエリを実行できます。これは非常に小さいため、リストの反復処理に特にコストはかかりません。

本当に単純にしたい場合は、静的な LookupRelations クラスで関数をラップできます。

于 2012-10-16T12:24:00.533 に答える