From a third-party program, I get an list of results, as follows:
+--------+-----------+-------------+
+ Name + Property + Prop. value +
+--------+-----------+-------------+
+ foo + prop1 + value1 +
+--------+-----------+-------------+
+ foo + prop2 + value2 +
+--------+-----------+-------------+
There is a dozen property and each of those may or may not exist.
The aim is to create .NET object from these.
Right now, I use LINQ to populate objects (sorry, VB, but it is quite straightforward):
New myClass With {
.myprop1 = (From o In query.rows where o.name = 'foo' and o.col(1) = 'prop1' select o.col(2)).FirstOrDefault
...
.myprop12 = (From o In query.rows where o.name = 'foo' and o.col(1) = 'prop12' select o.col(2)).FirstOrDefault
So I have basically the same line of code 12 times. I would like to simplify it.
I have in mind something like a Dictionary(Property, String)
, where I could define
myprop1 <-> prop1
....
myprop12 <-> prop12
And then loop over this. I haven't figured out how to do it. Is this possible? Is there any other way to make this kind of assignements less tedious?