To do this, you will need to use Raw SQL, which contains all the fields you need, and create a new model that matches SQL, so for this example you would do something like:
public class ShipperDetail { public int ShipperId { get; set; } public string CompanyName { get; set; } public string Phone { get; set; } public string ShipperTypeName { get; set; } } var rows = dbCmd.Select<ShipperDetail>( @"SELECT ShipperId, CompanyName, Phone, ST.Name as ShipperTypeName FROM Shippers S INNER JOIN ShipperTypes ST ON S.ShipperTypeId = ST.ShipperTypeId"); Console.WriteLine(rows.Dump());
To deduce the following:
[ { ShipperId: 2, CompanyName: Planes R Us, Phone: 555-PLANES, ShipperTypeName: Planes }, { ShipperId: 3, CompanyName: We do everything!, Phone: 555-UNICORNS, ShipperTypeName: Planes }, { ShipperId: 4, CompanyName: Trains R Us, Phone: 666-TRAINS, ShipperTypeName: Trains } ]
mythz
source share