Note that there are some explanatory texts on larger screens.

plurals
  1. PODapper.NET multi mapping TSecond Deserializer is null
    text
    copied!<p>I'm trying to perform a very standard multi mapping query using Dapper, and I'm getting the following error. I also get another error occasionally when this seems to work, but I'm unable to reproduce it at the moment. I'll append it to this post if/when the first problem is solved.</p> <p>Here is the query code:</p> <pre><code> const string storedProc = "dbo.GetStopsForRouteID"; var stops = conn.Query&lt;RouteStop, MapLocation, RouteStop&gt;( storedProc, (stop, loc) =&gt; { stop.Location = loc; return stop; }, new { RouteID = routeId }, commandType: CommandType.StoredProcedure); </code></pre> <p>In Dapper.cs on line 498:</p> <pre><code>var deserializer2 = (Func&lt;IDataReader, TSecond&gt;)info.OtherDeserializers[0]; </code></pre> <p>info.OtherDeserializers is null which causes a NullReferenceException.</p> <p>This is the guts of the stored procedure:</p> <pre><code>SELECT RouteStops.StopID, RouteStops.Name, RouteStops.Description, RouteStops.IsInbound, RouteStops.Location.Lat as Latitude, RouteStops.Location.Long as Longitude FROM dbo.Routes INNER JOIN dbo.StopsOnRoute ON Routes.RouteID = StopsOnRoute.RouteID INNER JOIN dbo.RouteStops ON StopsOnRoute.StopID = RouteStops.StopID WHERE Routes.RouteID = @RouteID ORDER BY StopsOnRoute.SequenceNumber </code></pre> <p>I've had an extensive look at the dapper code but I can't find anything that seems out of place other than that TFirst's deserialiser isn't null, but TSecond's is. Could there be a problem when it creates TSecond's deserializer that leaves it as null?</p> <p>Here are the types:</p> <pre><code>public class MapLocation { public double Latitude { get; set; } public double Longitude { get; set; } } public class RouteStop { public int StopID { get; set; } public string Name { get; set; } public string Description { get; set; } public bool IsInbound { get; set; } public MapLocation Location { get; set; } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload