Skip to the content.

Result type cannot be constructed

The generated materializer needs a way to create an instance of the result type: an accessible parameterless constructor, or a single usable constructor (or [ExplicitConstructor], or a factory method) whose parameters correspond to the type’s members. This type has none of those, so Dapper.AOT leaves the call-site on vanilla Dapper - which may work there via runtime configuration such as type handlers (SqlMapper.AddTypeHandler), but that mechanism is not available to AOT-generated code.

Examples of types that hit this: System.Data.Entity.Spatial.DbGeography (no accessible constructor; vanilla uses type handlers from Dapper.EntityFramework), and System.Data.Linq.Binary (only a byte[] constructor, which does not correspond to a member).

To use such a type with Dapper.AOT: give the type an accessible parameterless constructor or a suitable constructor/factory method, or use a different type for the query and convert afterwards.