I'm trying to pass a column name to a class and retrieve a value for that column from a sql database. Looks like Field<> is not available for a Table, but it will work with DataTable. Can someone point me how can i do it using linq? I'm sure it is a very simple thing. Thanks.
[Table(Name = "[Keys]")]
public class Keys
{
[Column]
public string Column_A{ get; set; }
[Column]
public string Column_B{ get; set; }
[Column]
public string Column_C{ get; set; }
}
public string ReadKey(string DBKey)
{
DataContext dc = new DataContext(sqlconn);
Table<Keys> keysTable = dc.GetTable<Keys>();
var query = from k in keysTable.AsEnumerable()
select k.Field<string>("DBKey"); <---------------- wrong
}