In Mono 3.2.5, code
var Record = GetRecord().First();
Record["Dokumnr"];
public IEnumerable<IDataRecord> GetRecord() {
using (var connection = new NpgsqlConnection("host=localhost;user=me"))
{
connection.Open();
DbCommand command = (DbCommand)connection.CreateCommand();
command.CommandText = "select * from sometable";
using (command)
{
using (DbDataReader reader = command.ExecuteReader())
{
foreach (DbDataRecord record in reader)
{
yield return new MyDynamicRecord(record);
}
}
}
}
}
causes IndexOutOfRangeException
Using lower case Record["dokumnr"]
works OK.
In ASP.NET MVC4 Record["Dokumnr"] works.
How to force case-insensitive column name indexer in Mono 3.2.5 ?
Using Npgsql data provider in ASP.NET MVC4 application in Debian Linux.
I've not tested, but give a try. Make use of IDataRecord.GetOrdinal
method.
var columnOrdinal = Record.GetOrdinal("Dokumnr");
var value = Record[columnOrdinal];
Am not sure about your DB Provider, but Sql will return treat case insensitive.