public void WhenCalledShouldAddPersistentPropertiesExclusionsPattern() { var orm = new ObjectRelationalMapper(); var oldCount = orm.Patterns.PersistentPropertiesExclusions.Count; orm.ExcludeProperty(mi=> mi.DeclaringType != typeof(Person)); orm.Patterns.PersistentPropertiesExclusions.Count.Should().Be(oldCount + 1); }
public void WhenExplicitDeclaredExclusionThenNoPersistent() { var orm = new ObjectRelationalMapper(); orm.ExcludeProperty <MyEntity>(me => me.NoReadOnly); orm.IsPersistentProperty(typeof(MyEntity).GetProperty("NoReadOnly")).Should().Be.False(); }
public void WhenCalledShouldAddPersistentPropertiesExclusionsPattern() { var orm = new ObjectRelationalMapper(); var oldCount = orm.Patterns.PersistentPropertiesExclusions.Count; orm.ExcludeProperty(mi => mi.DeclaringType != typeof(Person)); orm.Patterns.PersistentPropertiesExclusions.Count.Should().Be(oldCount + 1); }
public void WhenRegisterExclusionPropertyOnInterfaceThenShouldExcludePropertyOfConcreteImpl() { var orm = new ObjectRelationalMapper(); orm.TablePerClass<Person>(); orm.ExcludeProperty<IEntity>(p => p.Something); orm.IsPersistentProperty(ForClass<Person>.Property(p => p.Something)).Should().Be.False(); }
public void WhenRegisterExclusionPropertyOnInterfaceThenShouldExcludePropertyOfConcreteImpl() { var orm = new ObjectRelationalMapper(); orm.TablePerClass <Person>(); orm.ExcludeProperty <IEntity>(p => p.Something); orm.IsPersistentProperty(ForClass <Person> .Property(p => p.Something)).Should().Be.False(); }
public void WhenInterfaceOnParentAndPropertyExclusionOnImplThenNoMatch() { var orm = new ObjectRelationalMapper(); orm.TablePerClass <Node>(); orm.ExcludeProperty <Node>(x => x.ParentNode); var pattern = new PolymorphismBidirectionalOneToManyMemberPattern(orm); pattern.Match(ForClass <Node> .Property(x => x.SubNodes)).Should().Be.False(); }
/// <summary> /// Initializes the mappings. /// </summary> /// <param name="orm">The orm.</param> /// <param name="mapper">The mapper.</param> public void InitMappings(ObjectRelationalMapper orm, Mapper mapper) { // list all the entities we want to map. IEnumerable<Type> baseEntities = ListOfModelTypes(); // we map non Content classes as normal orm.TablePerClass(baseEntities); orm.Poid<AppSetting>(item => item.Id); mapper.Customize<AppSetting>(mapping => mapping.Property(item => item.Value, pm => pm.Length(255))); mapper.Customize<User>(mapping => { mapping.Property(item => item.Email, pm => pm.Unique(true)); mapping.Property(item => item.Password, pm => pm.Length(64)); }); orm.ExcludeProperty<User>(item => item.IsAuthenticated); orm.ExcludeProperty<User>(item => item.AuthenticationType); }
public void WhenInterfaceOnChildAndPropertyExclusionOnInterfaceThenNoMatch() { var orm = new ObjectRelationalMapper(); orm.TablePerClass <Parent>(); orm.TablePerClass <Child>(); orm.ExcludeProperty <IChild>(c => c.Parent); var pattern = new PolymorphismBidirectionalOneToManyMemberPattern(orm); pattern.Match(ForClass <Parent> .Property(x => x.Children)).Should().Be.False(); }
public void AskForPersistentPropertyShouldUsePersistentPropertiesExclusionsPattern() { // This test look like an example and a test related to the predicate passed to orm.ExcludeProperty ; btw match the scope. var orm = new ObjectRelationalMapper(); orm.ExcludeProperty(mi => mi.DeclaringType != typeof(Person) && typeof(Person).IsAssignableFrom(mi.DeclaringType)); orm.IsPersistentProperty(ForClass<Person>.Property(x => x.Id)).Should().Be.True(); orm.IsPersistentProperty(ForClass<Person>.Property(x => x.Name)).Should().Be.True(); orm.IsPersistentProperty(ForClass<Student>.Property(x => x.Grade)).Should().Be.False(); orm.IsPersistentProperty(ForClass<Student>.Property(x => x.Class)).Should().Be.False(); orm.IsPersistentProperty(ForClass<Clerk>.Property(x => x.Company)).Should().Be.False(); orm.IsPersistentProperty(ForClass<OutSideHierarchy>.Property(x => x.Id)).Should().Be.True(); orm.IsPersistentProperty(ForClass<OutSideHierarchy>.Property(x => x.Name)).Should().Be.True(); }
public void AskForPersistentPropertyShouldUsePersistentPropertiesExclusionsPattern() { // This test look like an example and a test related to the predicate passed to orm.ExcludeProperty ; btw match the scope. var orm = new ObjectRelationalMapper(); orm.ExcludeProperty(mi => mi.DeclaringType != typeof(Person) && typeof(Person).IsAssignableFrom(mi.DeclaringType)); orm.IsPersistentProperty(ForClass <Person> .Property(x => x.Id)).Should().Be.True(); orm.IsPersistentProperty(ForClass <Person> .Property(x => x.Name)).Should().Be.True(); orm.IsPersistentProperty(ForClass <Student> .Property(x => x.Grade)).Should().Be.False(); orm.IsPersistentProperty(ForClass <Student> .Property(x => x.Class)).Should().Be.False(); orm.IsPersistentProperty(ForClass <Clerk> .Property(x => x.Company)).Should().Be.False(); orm.IsPersistentProperty(ForClass <OutSideHierarchy> .Property(x => x.Id)).Should().Be.True(); orm.IsPersistentProperty(ForClass <OutSideHierarchy> .Property(x => x.Name)).Should().Be.True(); }
public void WhenExplicitDeclaredExclusionThenNoPersistent() { var orm = new ObjectRelationalMapper(); orm.ExcludeProperty<MyEntity>(me => me.NoReadOnly); orm.IsPersistentProperty(typeof(MyEntity).GetProperty("NoReadOnly")).Should().Be.False(); }