Exemplo n.º 1
0
        /// <summary>
        /// Property Level: Removes the existing mapped property handler from a data entity type property (via <see cref="Field"/> object).
        /// </summary>
        /// <typeparam name="TEntity">The target .NET CLR type.</typeparam>
        /// <param name="field">The instance of <see cref="Field"/> object to be mapped.</param>
        public static void Remove <TEntity>(Field field)
            where TEntity : class
        {
            // Validates
            ThrowNullReferenceException(field, "Field");

            // Get the property
            var property = TypeExtension.GetProperty <TEntity>(field.Name);

            if (property == null)
            {
                throw new PropertyNotFoundException($"Property '{field.Name}' is not found at type '{typeof(TEntity).FullName}'.");
            }

            // Add to the mapping
            Remove <TEntity>(property);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Property Level: Adds a mapping between a data entity type property and a <see cref="DbType"/> object (via property name).
        /// </summary>
        /// <typeparam name="TEntity">The type of the data entity.</typeparam>
        /// <param name="propertyName">The name of the class property to be mapped.</param>
        /// <param name="dbType">The name of the class property to be mapped.</param>
        /// <param name="force">A value that indicates whether to force the mapping. If one is already exists, then it will be overwritten.</param>
        public static void Add <TEntity>(string propertyName,
                                         DbType?dbType,
                                         bool force)
            where TEntity : class
        {
            // Validates
            ThrowNullReferenceException(propertyName, "PropertyName");

            // Get the property
            var property = TypeExtension.GetProperty <TEntity>(propertyName);

            if (property == null)
            {
                throw new PropertyNotFoundException($"Property '{propertyName}' is not found at type '{typeof(TEntity).FullName}'.");
            }

            // Add to the mapping
            Add <TEntity>(property, dbType, force);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Property Level: Gets the cached <see cref="DbType"/> object that is being mapped on a specific class property (via <see cref="Field"/> object).
 /// </summary>
 /// <typeparam name="TEntity">The type of the data entity.</typeparam>
 /// <param name="field">The instance of <see cref="Field"/> object.</param>
 /// <returns>The mapped <see cref="DbType"/> object of the property.</returns>
 public static DbType?Get <TEntity>(Field field)
     where TEntity : class =>
 Get <TEntity>(TypeExtension.GetProperty <TEntity>(field.Name));
Exemplo n.º 4
0
 /// <summary>
 /// Property Level: Gets the cached <see cref="DbType"/> object that is being mapped on a specific class property (via property name).
 /// </summary>
 /// <typeparam name="TEntity">The type of the data entity.</typeparam>
 /// <param name="propertyName">The name of the property.</param>
 /// <returns>The mapped <see cref="DbType"/> object of the property.</returns>
 public static DbType?Get <TEntity>(string propertyName)
     where TEntity : class =>
 Get <TEntity>(TypeExtension.GetProperty <TEntity>(propertyName));
Exemplo n.º 5
0
 /// <summary>
 /// Property Level: Removes the mapped <see cref="DbType"/> object of the data entity type property (via <see cref="Field"/> object).
 /// </summary>
 /// <typeparam name="TEntity">The target .NET CLR type.</typeparam>
 /// <param name="field">The instance of <see cref="Field"/> object.</param>
 public static void Remove <TEntity>(Field field)
     where TEntity : class =>
 Remove(typeof(TEntity), TypeExtension.GetProperty <TEntity>(field.Name));
Exemplo n.º 6
0
 /// <summary>
 /// Property Level: Removes the mapped <see cref="DbType"/> object of the data entity type property (via property name).
 /// </summary>
 /// <typeparam name="TEntity">The target .NET CLR type.</typeparam>
 /// <param name="propertyName">The name of the property.</param>
 public static void Remove <TEntity>(string propertyName)
     where TEntity : class =>
 Remove(typeof(TEntity), TypeExtension.GetProperty <TEntity>(propertyName));
Exemplo n.º 7
0
 /// <summary>
 /// Property Level: Gets the cached property handler object that is being mapped on a specific class property (via <see cref="Field"/> object).
 /// </summary>
 /// <typeparam name="TEntity">The type of the data entity.</typeparam>
 /// <typeparam name="TPropertyHandler">The type of the handler.</typeparam>
 /// <param name="field">The instance of <see cref="Field"/> object.</param>
 /// <returns>The mapped property handler object of the property.</returns>
 public static TPropertyHandler Get <TEntity, TPropertyHandler>(Field field)
     where TEntity : class =>
 Get <TEntity, TPropertyHandler>(TypeExtension.GetProperty <TEntity>(field.Name));
Exemplo n.º 8
0
 /// <summary>
 /// Property Level: Gets the cached property handler object that is being mapped on a specific class property (via property name).
 /// </summary>
 /// <typeparam name="TEntity">The type of the data entity.</typeparam>
 /// <typeparam name="TPropertyHandler">The type of the handler.</typeparam>
 /// <param name="propertyName">The name of the property.</param>
 /// <returns>The mapped property handler object of the property.</returns>
 public static TPropertyHandler Get <TEntity, TPropertyHandler>(string propertyName)
     where TEntity : class =>
 Get <TEntity, TPropertyHandler>(TypeExtension.GetProperty <TEntity>(propertyName));