コード例 #1
0
        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));
        }
コード例 #2
0
        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"));
        }
コード例 #3
0
        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"));
        }
コード例 #4
0
        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"));
        }
コード例 #5
0
        public void NavigationPropertiesUnmap()
        {
            var entityMapper = new EntityMapper <BaseEntityModel>();

            Assert.IsFalse(entityMapper.GetEntityMapping().Any(e => e.FullPath == "CreatedBy" || e.FullPath == "UpdatedBy"));
        }