我们有一个静态读取我们需要定期咨询的信息表。事实是此数据是相关的,我们需要能够使用任何其他相关属性作为index ...
获取任何属性在一个或两种情况下,其中一个属性可以在行之间重复,但很少发生...(请参见ofdr value)
)示例:
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定义和方法将如何?
给定小数据集,最好的选择是创建一个持有所有值并将其全部加载到内存
的类(或struct)public class Relations
{
public int formtypex;
public int objectcode;
public string table;
public string description;
}
您可以将其放在列表中,然后使用Linq查询。它是如此之小,以至于整个列表的迭代不会特别昂贵。
如果您希望它真的很简单,则可以将功能包装在静态查找类中。