I have a History table with columns C0, C1, C2, C3, TimeStamp.
I want to select a specific column based on input along with corresponding TimeStamp.
Let channelId be 'C2'
var context = new DalModels.DbContext();
string command = "SELECT TimeStamp, @channelId FROM dbo.History";
var user = new SqlParameter("@channelId", channelId);
var result = context.History.FromSql(command, user).ToList();
But instead of a result, I get an exception:
No column name was specified for column 2 of 'h'.
Invalid column name 'C0'.
Invalid column name 'C1'.
Invalid column name 'C2'.
Invalid column name 'C3'.
Invalid column name 'TimeStamp'.