After upgrading to .NET 8 and SS 8.01, I’m suddenly getting IndexOutOfRangeException for simple Select.
This code, which I’ve been using for a while:
public List<Employee> GetEmployees()
{
using var db = DbFactory.OpenDbConnection();
return db.Select<Employee>();
}
Gives this output:
Unhandled exception. System.IndexOutOfRangeException: Index was outside the bounds of the array.
at ServiceStack.OrmLite.OrmLiteUtils.HandleException(Exception ex, String message, Object[] args) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack.OrmLite/src/ServiceStack.OrmLite/OrmLiteUtils.cs:line 40
at ServiceStack.OrmLite.OrmLiteWriteCommandExtensions.PopulateObjectWithSqlReader[T](IOrmLiteDialectProvider dialectProvider, Object objWithProperties, IDataReader reader, Tuple`3[] indexCache, Object[] values) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack.OrmLite/src/ServiceStack.OrmLite/OrmLiteWriteCommandExtensions.cs:line 382
at ServiceStack.OrmLite.OrmLiteWriteCommandExtensions.PopulateWithSqlReader[T](T objWithProperties, IOrmLiteDialectProvider dialectProvider, IDataReader reader, Tuple`3[] indexCache, Object[] values) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack.OrmLite/src/ServiceStack.OrmLite/OrmLiteWriteCommandExtensions.cs:line 330
at ServiceStack.OrmLite.OrmLiteUtils.ConvertToList[T](IDataReader reader, IOrmLiteDialectProvider dialectProvider, HashSet`1 onlyFields) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack.OrmLite/src/ServiceStack.OrmLite/OrmLiteUtils.cs:line 266
at ServiceStack.OrmLite.OrmLiteResultsFilterExtensions.ExprConvertToList[T](IDbCommand dbCmd, String sql, IEnumerable`1 sqlParams, HashSet`1 onlyFields) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack.OrmLite/src/ServiceStack.OrmLite/OrmLiteResultsFilterExtensions.cs:line 143
at ServiceStack.OrmLite.ReadExpressionCommandExtensions.Select[T](IDbCommand dbCmd, SqlExpression`1 q) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack.OrmLite/src/ServiceStack.OrmLite/Expressions/ReadExpressionCommandExtensions.cs:line 15
at ServiceStack.OrmLite.OrmLiteReadExpressionsApi.<>c__DisplayClass34_0`1.<Select>b__0(IDbCommand dbCmd) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack.OrmLite/src/ServiceStack.OrmLite/OrmLiteReadExpressionsApi.cs:line 266
at ServiceStack.OrmLite.OrmLiteExecFilter.Exec[T](IDbConnection dbConn, Func`2 filter) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack.OrmLite/src/ServiceStack.OrmLite/OrmLiteExecFilter.cs:line 68
at ServiceStack.OrmLite.OrmLiteReadExpressionsApi.Exec[T](IDbConnection dbConn, Func`2 filter) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack.OrmLite/src/ServiceStack.OrmLite/OrmLiteReadExpressionsApi.cs:line 18
at ServiceStack.OrmLite.OrmLiteReadExpressionsApi.Select[T](IDbConnection dbConn, SqlExpression`1 expression) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack.OrmLite/src/ServiceStack.OrmLite/OrmLiteReadExpressionsApi.cs:line 266
at ... // continues with my code
I’ve used the BeforeExecFilter, copied the SQL to the same DB and I’m getting results from the query.
// to serialize complex objects as JSON instead of JSV
SqlServerDialect.Provider.StringSerializer = new JsonStringSerializer();
OrmLiteConfig.BeforeExecFilter = dbCmd => OrmLiteUtils.PrintSql(); // turn on for DEBUG
var connectionString = Configuration.GetConnectionString("DbConnectionString");
var dialectProvider = SqlServer2019Dialect.Provider;
var dbFactory = new OrmLiteConnectionFactory(connectionString, dialectProvider);
container.Register<IDbConnectionFactory>(dbFactory);