Using ORMSupportClasses v2.6.09.0305 vs. SQL Server.
So I am investigating using projections for the first time, mainly as a replacement for datasets/dynamic lists in cases where I want a strongly typed custom object.
I currently have some code that works fine as a dynamic list, and wanted to see if it's possible to do easily with projections. As an example, say I have a Order table that has a personId column on it. The personId represents the sales rep that placed the order, which can be null if the order was placed without a sales rep's help.
Currently I fetch a Datatable and then manually create an anonymous type. Something like the following (note that this is a made-up example and the code may not be exactly right):
var list = new List<object>();
foreach (DataRow row in dataTable.Rows)
{
var userName = string.Empty;
if (row[PersonFields.FirstName.Name] != DBNull.Value && row[PersonFields.LastName.Name] != DBNull.Value)
{
personName = row[PersonFields.FirstName.Name] + " " + row[PersonFields.LastName.Name];
}
list.Add(new
{
UserName = personName
});
}
So basically I am checking to see if the person table returned null in the left join; if it's null, I show string.empty, and if it's non-null, I show the values.
Is it possible (and recommended) to do this kind of thing with a projection?
Thanks,
Phil