DataTable dtConfig = new DataTable("CONFIG");
dtConfig.Columns.Add(new DataColumn("key", typeof(System.String)));
dtConfig.Columns.Add(new DataColumn("value", typeof(System.String)));
dtConfig.Rows.Add("foo", "bar");
dtConfig.Rows.Add("connString", "Data Source=urmum");
Will give you a datatable like this
|key |value |
|----------|-----------------|
|foo |bar |
|connString|Data Source=urmum|
Assume that we're using the dtConfig from the last example
var config = (from row in dtConfig.AsEnumerable()
select new
{
key = row.Field<string>("key"),
value = row.Field<string>("value")
}
).AsEnumerable().ToDictionary(k => k.key, v => v.value);
Console.WriteLine("connString: {0}",config["connString"]);
string whereClause = @"FOO = '123'";
string orderBy = "BAR DESC";
dt.Select(whereClause, orderBy);