Whichever way I do it, it seems something goes wrong when using the conditional operator on enum values in Linq to Sql. For example
var ret = from listings in db.Listings
select new Listing
{
ID = listings.ID,
//etc
OrderStatus = listings.OrderItems.Count > 0
? listings.OrderItems.First().Order.OrderStatus : OrderStatus.NotCheckedOut
};
System.Data.SqlClient.SqlException: Conversion failed when converting the nvarchar value 'Charged' to data type int..
When I leave the enum field as nvarchar mapped to a string I get similar conversion errors. How to workaround this ?