Exemplo n.º 1
0
        /// <summary>
        /// Gets the mapped name of the propery.
        /// </summary>
        /// <param name="property">The property where the mapped name will be retrieved.</param>
        /// <returns>A string containing the mapped name.</returns>
        public static string GetMappedName(this PropertyInfo property)
        {
            var attribute = (MapAttribute)GetCustomAttribute(property, typeof(MapAttribute));

            return(attribute?.Name ??
                   PropertyMapper.Get(property) ??
                   property.Name);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the mapped name of the propery.
        /// </summary>
        /// <param name="property">The property where the mapped name will be retrieved.</param>
        /// <returns>A string containing the mapped name.</returns>
        public static string GetMappedName(this PropertyInfo property)
        {
            var attributeName = ((MapAttribute)GetCustomAttribute(property, StaticType.MapAttribute))?.Name ??
                                ((ColumnAttribute)GetCustomAttribute(property, StaticType.ColumnAttribute))?.Name;

            return(attributeName ??
                   PropertyMapper.Get(property) ??
                   property.Name);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets the mapped name of the property.
        /// </summary>
        /// <param name="property">The property where the mapped name will be retrieved.</param>
        /// <param name="declaringType">The declaring type of the property.</param>
        /// <returns>A string containing the mapped name.</returns>
        internal static string GetMappedName(this PropertyInfo property,
                                             Type declaringType)
        {
            var mappedName = ((MapAttribute)GetCustomAttribute(property, StaticType.MapAttribute))?.Name ??
                             ((ColumnAttribute)GetCustomAttribute(property, StaticType.ColumnAttribute))?.Name ??
                             ((NameAttribute)GetCustomAttribute(property, StaticType.NameAttribute))?.Name;

            return(mappedName ??
                   PropertyMapper.Get(declaringType, property) ??
                   GetPropertyValueAttribute <NameAttribute>(property, declaringType, true)?.Name ??
                   property.Name);
        }
Exemplo n.º 4
0
        public void TestFluentMapColumnMappingOverride()
        {
            // Setup
            FluentMapper
            .Entity <FluentMapperTestClass>()
            .Column(e => e.PropertyString, "ColumnStringOverriden", true);

            // Act
            var actual   = PropertyMapper.Get <FluentMapperTestClass>(e => e.PropertyString);
            var expected = "ColumnStringOverriden";

            // Assert
            Assert.AreEqual(expected, actual);
        }