public static IQueryable <TEntity> WhereIdMatches <TEntity>(this IQueryable <TEntity> queryable, IEnumerable entityIds) { var entityMapper = new EntityMapper <TEntity>(); var idProperty = entityMapper.GetEntityMapping().Where(m => m.IsKey).Select(m => m.Property).FirstOrDefault(); return(queryable.WherePropertyMatches(idProperty.Name, idProperty.PropertyType, entityIds)); }
public void AccessToDeclaredProperty() { var processor = new HierarchyProcessor(); var classMap = new BsonClassMap <ChildTestModel>(); processor.ApplyMapping(typeof(ChildTestModel), classMap); var entityMapper = new EntityMapper <ChildTestModel>(); var mappedProperties = entityMapper.GetEntityMapping(); Assert.IsTrue(mappedProperties.Any(p => p.ElementName == "DeclaredProperty")); }
public void ObeysColumnAttributeRemap() { var processor = new MappedPropertiesProcessor(); var classMap = new BsonClassMap <ColumnAttributePropertyModel>(); classMap.AutoMap(); processor.ApplyMapping(typeof(ColumnAttributePropertyModel), classMap); var entityMapper = new EntityMapper <ColumnAttributePropertyModel>(); var mappedProperties = entityMapper.GetEntityMapping(); Assert.IsTrue(mappedProperties.Any(p => p.ElementName == "CustomPropertyName")); }
public void ObeysNotMappedAttribute() { var processor = new MappedPropertiesProcessor(); var classMap = new BsonClassMap <NotMappedPropertiesModel>(); classMap.AutoMap(); processor.ApplyMapping(typeof(NotMappedPropertiesModel), classMap); var entityMapper = new EntityMapper <NotMappedPropertiesModel>(); var mappedProperties = entityMapper.GetEntityMapping(); Assert.IsFalse(mappedProperties.Any(p => p.ElementName == "NotMapped")); }
public void NavigationPropertiesUnmap() { var entityMapper = new EntityMapper <BaseEntityModel>(); Assert.IsFalse(entityMapper.GetEntityMapping().Any(e => e.FullPath == "CreatedBy" || e.FullPath == "UpdatedBy")); }