In the recipe Using calculated properties we learned how to use SQL expressions to provide custom calculations
for specific properties. Using a <subselect>
mapping we can to the same for an entire class.
Add a new folder named
MappingSubselects
to theMappingRecipes
project.Add a new class named
PageHit
to the folder:using System; namespace MappingRecipes.MappingSubselects { public class PageHit { public virtual int Id { get; protected set; } public virtual string Url { get; set; } public virtual DateTime PageViewDateTime { get; set; } } }
Add a new class named
PageStatisticsEntry
to the folder:namespace MappingRecipes.MappingSubselects { public class PageStatisticsEntry { public virtual string Url { get; protected set; } public virtual int ViewCount { get; protected set; } } }