public SagaModelMapper(IEnumerable <Type> typesToScan) { Mapper = new ConventionModelMapper(); _sagaEntities = typesToScan.Where(t => typeof(IContainSagaData).IsAssignableFrom(t) && !t.IsInterface); _entityTypes = GetTypesThatShouldBeAutoMapped(_sagaEntities, typesToScan); Mapper.IsTablePerClass((type, b) => false); Mapper.IsTablePerConcreteClass((type, b) => _sagaEntities.Contains(type)); Mapper.IsTablePerClassHierarchy((type, b) => false); Mapper.IsEntity((type, mapped) => _entityTypes.Contains(type)); Mapper.IsArray((info, b) => false); Mapper.IsBag((info, b) => { var memberType = info.GetPropertyOrFieldType(); return(typeof(IEnumerable).IsAssignableFrom(memberType) && !(memberType == typeof(string) || memberType == typeof(byte[]) || memberType.IsArray)); }); Mapper.IsPersistentProperty((info, b) => !HasAttribute <RowVersionAttribute>(info)); Mapper.BeforeMapClass += ApplyClassConvention; Mapper.BeforeMapUnionSubclass += ApplySubClassConvention; Mapper.BeforeMapProperty += ApplyPropertyConvention; Mapper.BeforeMapBag += ApplyBagConvention; Mapper.BeforeMapManyToOne += ApplyManyToOneConvention; }
SagaModelMapper(SagaMetadataCollection allMetadata, IEnumerable <Type> typesToScan, Func <Type, string> tableNamingConvention = null) { this.tableNamingConvention = tableNamingConvention ?? DefaultTableNameConvention; mapper = new ConventionModelMapper(); this.typesToScan = typesToScan.ToList(); sagaMetaModel = allMetadata; sagaEntities = this.typesToScan.Where(t => typeof(IContainSagaData).IsAssignableFrom(t) && !t.IsInterface).ToList(); PopulateTypesThatShouldBeAutoMapped(); mapper.IsTablePerClass((type, b) => false); mapper.IsTablePerConcreteClass((type, b) => sagaEntities.Contains(type)); mapper.IsTablePerClassHierarchy((type, b) => false); mapper.IsEntity((type, mapped) => entityTypes.Contains(type)); mapper.IsArray((info, b) => false); mapper.IsBag((info, b) => { var memberType = info.GetPropertyOrFieldType(); return(typeof(IEnumerable).IsAssignableFrom(memberType) && !(memberType == typeof(string) || memberType == typeof(byte[]) || memberType.IsArray)); }); mapper.IsPersistentProperty((info, b) => !HasAttribute <RowVersionAttribute>(info)); mapper.BeforeMapClass += ApplyClassConvention; mapper.BeforeMapUnionSubclass += ApplySubClassConvention; mapper.BeforeMapProperty += ApplyPropertyConvention; mapper.BeforeMapBag += ApplyBagConvention; mapper.BeforeMapManyToOne += ApplyManyToOneConvention; }
public SagaModelMapper(IEnumerable <Type> typesToScan) { Mapper = new ConventionModelMapper(); _sagaEntites = typesToScan.Where(t => typeof(ISagaEntity).IsAssignableFrom(t) && !t.IsInterface); _entityTypes = GetTypesThatShouldBeAutoMapped(_sagaEntites, typesToScan); Mapper.IsEntity((type, b) => _entityTypes.Contains(type)); Mapper.IsArray((info, b) => false); Mapper.IsBag((info, b) => { var memberType = info.GetPropertyOrFieldType(); return(typeof(IEnumerable).IsAssignableFrom(memberType) && !(memberType == typeof(string) || memberType == typeof(byte[]) || memberType.IsArray)); }); Mapper.BeforeMapClass += ApplyClassConvention; Mapper.BeforeMapJoinedSubclass += ApplySubClassConvention; Mapper.BeforeMapProperty += ApplyPropertyConvention; Mapper.BeforeMapBag += ApplyBagConvention; Mapper.BeforeMapManyToOne += ApplyManyToOneConvention; }