/// <summary> /// Maps a property /// </summary> /// <param name="expression">The expression that returns the property to map</param> /// <returns>An helper to define the property mapping</returns> public FluentPropertyMapping <T> Property(Expression <Func <T, object> > expression) { var property = TableHelpers.GetExpressionPropertyInfo(expression); var propertyMapping = typeMapping.Columns[property.Name]; return(new FluentPropertyMapping <T>(propertyMapping)); }
/// <summary> /// Defines the primary key /// </summary> /// <param name="expression">An expression that selects the primary key</param> public void HasKey(Expression <Func <T, object> > expression) { var propertyInfo = TableHelpers.GetExpressionPropertyInfo(expression); typeMapping.Key = typeMapping.Columns[propertyInfo.Name]; typeMapping.Key.IsKey = true; if (propertyInfo.PropertyType == typeof(int) || propertyInfo.PropertyType == typeof(long)) { typeMapping.Key.IsAutomatic = true; } }