Пример #1
0
        /// <summary>
        /// Performs the passed in mappings on all subclasses of the given TEntityBase.
        /// </summary>
        /// <typeparam name="TEntityBase">
        /// An entity base class.
        /// </typeparam>
        /// <param name="baseEntityMappingAction">
        /// Fluent mappings that will be performed on all subclasses of the given TEntityBase.
        /// </param>
        /// <param name="assembliesToSearch">
        /// OPTIONAL.  The assemblies that will be searched for subclasses of TEntityBase.
        /// If none are passed in, only the Assembly that contains TEntityBase will be searched.
        /// </param>
        /// <returns></returns>
        public FluentMappings ForEachEntity <TEntityBase>(
            Action <MappingsFluentEntity <TEntityBase> > baseEntityMappingAction,
            params Assembly[] assembliesToSearch)
        {
            var assemblies = assembliesToSearch.Any() ? assembliesToSearch : new[] { typeof(TEntityBase).Assembly };
            var entityType = typeof(TEntityBase);

            var subclassTypesOfTEntity = assemblies
                                         .SelectMany(a => a.GetTypes().Where(t => entityType.IsAssignableFrom(t) && t.IsClass))
                                         .ToArray();

            // Apply mapping action to each TEntity subclass
            foreach (var subclassType in subclassTypesOfTEntity)
            {
                var subclassMappingsRoot = new MappingsFluentEntity <TEntityBase>(_publicOnly, subclassType);
                baseEntityMappingAction(subclassMappingsRoot);
            }

            return(this);
        }
Пример #2
0
 public MappingsFluentRelationships(MappingsFluentEntity <TEntity> fluentEntity, bool publicOnly)
 {
     _fluentEntity = fluentEntity;
     _publicOnly   = publicOnly;
 }
Пример #3
0
 public MappingsFluentColumns(MappingsFluentEntity <TEntity> fluentEntity, bool publicOnly)
 {
     _fluentEntity = fluentEntity;
     _publicOnly   = publicOnly;
 }
Пример #4
0
 public MappingsFluentTables(MappingsFluentEntity <TEntity> fluentEntity)
 {
     _fluentEntity = fluentEntity;
 }