Dapper
Dapper copied to clipboard
Null Ref Exception when using splitOn
I'm having trouble narrowing down what's causing this null ref to happen on dapper 2.0.4. The DB is mariadb 10.2 using MySqlConnector 2.1.8
System.NullReferenceException: Object reference not set to an instance of an object.
at Dapper.SqlMapper.<>c__DisplayClass158_0`8.<GenerateMapper>b__1(IDataReader r) in C:\projects\dapper\Dapper\SqlMapper.cs:line 1542
at Dapper.SqlMapper.MultiMapImpl[TFirst,TSecond,TThird,TFourth,TFifth,TSixth,TSeventh,TReturn](IDbConnection cnn, CommandDefinition command, Delegate map, String splitOn, IDataReader reader, Identity identity, Boolean finalize)+MoveNext() in C:\projects\dapper\Dapper\SqlMapper.cs:line 1442
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Dapper.SqlMapper.MultiMapAsync[TFirst,TSecond,TThird,TFourth,TFifth,TSixth,TSeventh,TReturn](IDbConnection cnn, CommandDefinition command, Delegate map, String splitOn) in C:\projects\dapper\Dapper\SqlMapper.Async.cs:line 949
at Thing.Common.Data.DbBase.GetBoardPanelsAsync(CgyDbType dbType, CurrentConfigs configs, Int32 userId, UInt32 boardId, Int32 maxRetries, Int32 retryDelay) in /Users/joephillips/repos/dotnet_e/Thing.Common.Data/DbBase.cs:line 6187
The code causing it seems to be related to the splitOn functionality being used here:
const string panelsSql = @"
SELECT p.panel_id, p.board_id, p.type_id, p.size_id, p.created_on, p.updated_on, p.custom_height, p.custom_width
FROM CAT.panels p
JOIN CAT.boards b ON b.board_id = p.board_id
WHERE p.board_id = @boardId
AND b.user_id = @userId;";
return await conn.Connection.QueryAsync<Panel, int, int, Panel>(
panelsSql,
(panel, width, height) => {
panel.CustomSize = new Common.Objects.CustomPanelSize { Width = width, Height = height };
return panel;
},
p,
splitOn: "custom_height, custom_width").ConfigureAwait(false);