public static IMapBuilderContext <TResult> MapAllProperties() { IMapBuilderContext <TResult> mapBuilderContext = (IMapBuilderContext <TResult>) new MapBuilder <TResult> .MapBuilderContext(); foreach (PropertyInfo property in ((IEnumerable <PropertyInfo>) typeof(TResult).GetProperties(BindingFlags.Instance | BindingFlags.Public)).Where <PropertyInfo>((Func <PropertyInfo, bool>)(property => MapBuilder <TResult> .IsAutoMappableProperty(property)))) { mapBuilderContext = mapBuilderContext.MapByName(property); } return(mapBuilderContext); }
private static bool IsAutoMappableProperty(PropertyInfo property) { return(property.CanWrite && property.GetIndexParameters().Length == 0 && !MapBuilder <TResult> .IsCollectionType(property.PropertyType)); }
public static IRowMapper <TResult> BuildAllProperties() { return(MapBuilder <TResult> .MapAllProperties().Build()); }