Пример #1
0
        /// <summary>
        /// Adds a mapping between .NET CLR Type and database type.
        /// </summary>
        /// <param name="item">The instance of type-mapping object that holds the mapping of .NET CLR Type and database type.</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 Map(TypeMapItem item, bool force = false)
        {
            var target = Get(item.Type);

            if (target == null)
            {
                m_cache.Add(item);
            }
            else
            {
                if (force == false)
                {
                    throw new DuplicateTypeMapException($"A mapping for type '{target.Type.FullName}' is already defined. It is currently mapped to '{target.DbType.GetType().FullName}' database type.");
                }
                else
                {
                    target.SetDbType(item.DbType);
                }
            }
        }
Пример #2
0
 /// <summary>
 /// Adds a mapping between .NET CLR Type and database type.
 /// </summary>
 /// <param name="item">The instance of type-mapping object that holds the mapping of .NET CLR Type and database type.</param>
 public static void Map(TypeMapItem item)
 {
     Map(item, false);
 }