private static object GetColumnValue (object entity, MappingResolverStub mappingResolver, SqlEntityDefinitionExpression sqlEntityDefinition, string columnName)
{
var propertiesWithColumnName =
entity.GetType()
.GetProperties()
.SelectMany (p => TryResolveProperty (mappingResolver, sqlEntityDefinition, p, entity), (p, t) => new { Property = p, ColumnNameAndValue = t })
.ToArray();
var matchingProperty = propertiesWithColumnName.FirstOrDefault (d => d.ColumnNameAndValue.Key == columnName);
// Assert.That (matchingProperties, Has.Length.LessThanOrEqualTo (1), entity.GetType().Name + ": " + string.Join (",", matchingProperties));
Assert.IsNotNull (
matchingProperty,
"No member found for column '{0}' on entity type '{1}'.\r\n(Found: {2})",
columnName,
entity.GetType().Name,
string.Join (",", propertiesWithColumnName.Select (p=> p.ToString())));
return matchingProperty.ColumnNameAndValue.Value;
}