-
Notifications
You must be signed in to change notification settings - Fork 73
Description
Could someone take a look and tell me why Order.OrderDetails is returning as null after the map. The sql works and there is order details in the database. I can get nesting working for the 1 level, but not 2.
btw - I may have a typo as I had to rename the class and fields but the sql does work and no exceptions are being thrown. It just can't find the data which is nested a the 2nd level.
public class Project
{
public long ProjectId { get; set; }
public IEnumerable Orders { get; set; }
}
public class Order
{
public long OrderId { get; set; }
public IEnumerable OrderDetails{ get; set; }
}
public class OrderDetail
{
public long OrderDetailId { get; set; }
}
var sql = $@"
SELECT
p.Project_ID AS ProjectId
o.Order_ID AS Order_OrderId,
od.Order_Detail_ID AS Order_OrderDetail_OrderDetailId,
FROM
Project AS p
LEFT JOIN Order AS o ON p.Order_ID = o.Order_ID
LEFT JOIN OrderDetail AS od ON o.Order_Detail_ID = od.Order_Detail_ID
";
Slapper.AutoMapper.Cache.ClearInstanceCache();
Slapper.AutoMapper.Configuration.AddIdentifiers(typeof(ProjectSampleSetLegacyPortal),
new List<string> { "ProjectId" });
Slapper.AutoMapper.Configuration.AddIdentifiers(typeof(StatsLegacyPortal),
new List<string> { "OrderId" });
Slapper.AutoMapper.Configuration.AddIdentifiers(typeof(StatsDetailLegacyPortal),
new List<string> { "OrderDetailId" });
var results =
Slapper.AutoMapper.MapDynamic<Project>(query).First();