Open
Description
I have a model class:
public class QueryResults
{
public double Distance { get; set; }
public string StreetLine1 { get; set; }
public string StreetLine2 { get; set; }
public string City { get; set; }
public string State { get; set; }
}
In my data access layer, one of the methods maps some of the model's fields.
var mappings = new ColumnMappingCollection();
// Start defining the mappings between each property/column for a type
mappings.RegisterType<QueryResults>()
.MapProperty(x => x.Distance).ToColumn("distance")
.MapProperty(x => x.StreetLine1).ToColumn("street1")
.MapProperty(x => x.StreetLine2).ToColumn("street2");
mappings.RegisterWithDapper();
string query = "SELECT distance, " +
"sites.street1, " +
"sites.street2, " +
"sites.city, " +
"sites.state, " +
"FROM mytable ";
// Execute my query using Dapper
IEnumerable<QueryResults> results = connection.Query<QueryResults>(query);
The results returned by the query do not include the unmapped properties/fields. Specifically, the City and State fields do not get populated.
Metadata
Metadata
Assignees
Labels
No labels