Null Ref Exception when using splitOn
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 18.4k
- Forks
- 3.7k
- Avg merge
- 5h 8m
- Merged PRs (30d)
- 1
Description
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);
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with Dapper/SqlMapper.cs at line 1542, then trace the MultiMapImpl path at line 1442. Reproduce the reported query using the Panel, int, int mapping and splitOn: "custom_height, custom_width" against the stated database and connector versions. Done means the null-reference cause is isolated and the behavior is verified for this case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, mysql, sql
- Domain
- backend, database
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 28/100