public void CreateIntersection_WithTypeConverter_Returns_Mapped_Converted_Fields() { var schema = new SchemaBuilder() .Define <EntityModel>() .Build(); var intersectionAnalyzer = new ClassToEntityIntersectionAnalyzer( new IIntersectCandidateSource <ViewIntersectionModel, ViewIntersectionField, ORM.Schema.EntityModel, EntityField>[] { new FlattenedNameMatchCandidateSource <ViewIntersectionModel, ViewIntersectionField, ORM.Schema.EntityModel, EntityField>() }, new IIntersectionRule <ViewIntersectionModel, ViewIntersectionField, ORM.Schema.EntityModel, EntityField>[] { new TypeConverterRule <ViewIntersectionModel, ViewIntersectionField, ORM.Schema.EntityModel, EntityField>( new ITypeConverter[] { new SubConverter() } ), new SameDataTypeRule <ViewIntersectionModel, ViewIntersectionField, ORM.Schema.EntityModel, EntityField>() } ); var intersection = intersectionAnalyzer.CreateIntersection( TypeModel.GetModelOf <ViewModel>(), schema.GetEntityModel <EntityModel>() ); Assert.IsNotNull(intersection); Assert.AreEqual(1, intersection.IntersectedFields.Length); Assert.IsInstanceOfType( intersection.IntersectedFields[0].LeftPath.Fields[0], typeof(ConvertedViewIntersectionField <ViewModelSub, EntityModelSub>) ); }
protected virtual EntityModel BuildEntityModel( ClassToEntityIntersectionAnalyzer classToEntityAnalyzer, IIntersectionAnalyzer <EntityModel, EntityField, TypeModel, PropertyInfoField> modelToTypeAnalyzer, EntityDefinition entityDefinition) { _joinCount = 1; var modelFields = entityDefinition.BuildEntityFields(this, entityDefinition, entityDefinition.TypeModel) .ToArray(); var indexes = entityDefinition.IndexBuilders.Select(q => q.Build(modelFields)); return(entityDefinition.BuildModel( classToEntityAnalyzer, modelToTypeAnalyzer, modelFields, indexes )); }
public static IEntityView <TView> Create <TEntity, TView>( ClassToEntityIntersectionAnalyzer classToEntityAnalyzer, IIntersectionAnalyzer <EntityModel, EntityField, TypeModel, PropertyInfoField> entityToTypeAnalyzer, EntityModel <TEntity> entityModel ) where TEntity : class where TView : class { var viewTypeModel = TypeModel.GetModelOf <TView>(); return(new EntityView <TView>( classToEntityAnalyzer.CreateIntersection(viewTypeModel, entityModel), entityToTypeAnalyzer.CreateIntersection(entityModel, viewTypeModel) )); }
protected virtual IEnumerable <EntityModel> BuildEntityModels() { var classToEntityAnalyzer = new ClassToEntityIntersectionAnalyzer( ClassToEntityCandidateSources, ClassToEntityRules ); var modelToTypeAnalyzer = new DefaultIntersectionAnalyzer <EntityModel, EntityField, TypeModel, PropertyInfoField>( EntityToTypeCandidateSources, EntityToTypeRules ); foreach (var entityDefinition in EntityDefinitions) { yield return(BuildEntityModel(classToEntityAnalyzer, modelToTypeAnalyzer, entityDefinition)); } }
public abstract EntityModel BuildModel( ClassToEntityIntersectionAnalyzer classToEntityAnalyzer, IIntersectionAnalyzer <EntityModel, EntityField, TypeModel, PropertyInfoField> modelToTypeAnalyzer, IEnumerable <EntityField> entityFields, IEnumerable <Index> indexes);