So, I want to make a single report in C#.
First I load the data using LINQ:
var query = (from c in customer
where c.id.Equals(customer_id)
orderby c.id
select c).FirstOrDefault();
Then I make the dictionary contain the field name in the database and a label.
Dictionary<string, string> list = new Dictionary<string, string>();
list.Add("name", "Full Name");
list.Add("address", "Address");
list.Add("phone", "Customer Phone");
list.Add("email", "Customer Email");
Basically I want to iterate the whole dictionary and using the key as a field name identifier:
foreach (var pair in list)
{
graphic.DrawString(pair.Value, font, brush, startX, startY + offset);
graphic.DrawString(":", font, brush, semicolonPos, startY + offset);
graphic.DrawString(query.[pair.Key], font, brush, semicolonPos, startY + offset); // This is not working, any suggestion?
offset += 40;
}
So my question is, is it possible to have something like **query.[pair.Key]**, or do you have any suggestions for this case?
I am basically a PHP programmer, so maybe my mindset is still on web programming :D. And sorry if my question is confusing.
1 Answer