JoinMapping

Namespace: FluentNHibernate
We found 10 examples in language CSharp for this search. You will see 48 fragments of code.
using System;
using System.Data;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace Norml.Common.Data.Mappings
{
    public class PropertyMapping
    {
        public PropertyMapping()
        {

        }

        [JsonConstructor()]
        public PropertyMapping(JoinMapping joinMapping)
        {
            JoinMapping = joinMapping;
        }

        public string PropertyName { get; set; }
        
        [JsonConverter(typeof(StringEnumConverter))]
        public SqlDbType DatabaseType { get; set; }

        public string ParameterName { get; set; }
        public bool IsIdentity { get; set; }
        public bool AllowDbNull { get; set; }
        public int Order { get; set; }
        public bool IsPrimaryKey { get; set; }
        public IJoinMapping JoinMapping { get; set; }
        public string SortColumn { get; set; }
        public string SortColumnAlias { get; set; }
        public string Field { get; set; }
        public bool IsPrimitive { get; set; }
        public string LazyLoader { get; set; }
        public Type MappedType { get; set; }
        public IMethodCache MethodCache { get; set; }
    }
}


        [SetUp]
        public void GetWriterFromContainer()
        {
            var container = new XmlWriterContainer();
            writer = container.Resolve<IXmlWriter<JoinMapping>>();
        }

        [Test]
        public void ShouldWriteTableAttribute()
        {
            var testHelper = new XmlWriterTestHelper<JoinMapping>();
            testHelper.Check(x => x.TableName, "tbl").MapsToAttribute("table");

            testHelper.VerifyAll(writer);
        }

        [Test]
        public void ShouldWriteSchemaAttribute()
        {
            var testHelper = new XmlWriterTestHelper<JoinMapping>();
            testHelper.Check(x => x.Schema, "dbo").MapsToAttribute("schema");

            testHelper.VerifyAll(writer);
        }

        [Test]
        public void ShouldWriteFetchAttribute()
        {
            var testHelper = new XmlWriterTestHelper<JoinMapping>();
            testHelper.Check(x => x.Fetch, "fetch").MapsToAttribute("fetch");

            testHelper.VerifyAll(writer);
        }

        [Test]
        public void ShouldWriteInverseAttribute()
        {

            var testHelper = new XmlWriterTestHelper<JoinMapping>();
            testHelper.Check(x => x.Inverse, true).MapsToAttribute("inverse");

            testHelper.VerifyAll(writer);
        }

        [Test]
        public void ShouldWriteOptionalAttribute()
        {
            var testHelper = new XmlWriterTestHelper<JoinMapping>();
            testHelper.Check(x => x.Optional, true).MapsToAttribute("optional");

            testHelper.VerifyAll(writer);
        }


        [SetUp]
        public void GetWriterFromContainer()
        {
            var container = new XmlWriterContainer();
            writer = container.Resolve<IXmlWriter<JoinMapping>>();
        }

        [Test]
        public void ShouldWriteTableAttribute()
        {
            var testHelper = new XmlWriterTestHelper<JoinMapping>();
            testHelper.Check(x => x.TableName, "tbl").MapsToAttribute("table");

            testHelper.VerifyAll(writer);
        }

        [Test]
        public void ShouldWriteSchemaAttribute()
        {
            var testHelper = new XmlWriterTestHelper<JoinMapping>();
            testHelper.Check(x => x.Schema, "dbo").MapsToAttribute("schema");

            testHelper.VerifyAll(writer);
        }

        [Test]
        public void ShouldWriteFetchAttribute()
        {
            var testHelper = new XmlWriterTestHelper<JoinMapping>();
            testHelper.Check(x => x.Fetch, "fetch").MapsToAttribute("fetch");

            testHelper.VerifyAll(writer);
        }

        [Test]
        public void ShouldWriteInverseAttribute()
        {

            var testHelper = new XmlWriterTestHelper<JoinMapping>();
            testHelper.Check(x => x.Inverse, true).MapsToAttribute("inverse");

            testHelper.VerifyAll(writer);
        }

        [Test]
        public void ShouldWriteOptionalAttribute()
        {
            var testHelper = new XmlWriterTestHelper<JoinMapping>();
            testHelper.Check(x => x.Optional, true).MapsToAttribute("optional");

            testHelper.VerifyAll(writer);
        }


        [SetUp]
        public void GetWriterFromContainer()
        {
            var container = new XmlWriterContainer();
            writer = container.Resolve<IXmlWriter<JoinMapping>>();
        }

        [Test]
        public void ShouldWriteTableAttribute()
        {
            var testHelper = new XmlWriterTestHelper<JoinMapping>();
            testHelper.Check(x => x.TableName, "tbl").MapsToAttribute("table");

            testHelper.VerifyAll(writer);
        }

        [Test]
        public void ShouldWriteSchemaAttribute()
        {
            var testHelper = new XmlWriterTestHelper<JoinMapping>();
            testHelper.Check(x => x.Schema, "dbo").MapsToAttribute("schema");

            testHelper.VerifyAll(writer);
        }

        [Test]
        public void ShouldWriteFetchAttribute()
        {
            var testHelper = new XmlWriterTestHelper<JoinMapping>();
            testHelper.Check(x => x.Fetch, "fetch").MapsToAttribute("fetch");

            testHelper.VerifyAll(writer);
        }

        [Test]
        public void ShouldWriteInverseAttribute()
        {

            var testHelper = new XmlWriterTestHelper<JoinMapping>();
            testHelper.Check(x => x.Inverse, true).MapsToAttribute("inverse");

            testHelper.VerifyAll(writer);
        }

        [Test]
        public void ShouldWriteOptionalAttribute()
        {
            var testHelper = new XmlWriterTestHelper<JoinMapping>();
            testHelper.Check(x => x.Optional, true).MapsToAttribute("optional");

            testHelper.VerifyAll(writer);
        }


        [SetUp]
        public void GetWriterFromContainer()
        {
            var container = new XmlWriterContainer();
            writer = container.Resolve<IXmlWriter<JoinMapping>>();
        }

        [Test]
        public void ShouldWriteTableAttribute()
        {
            var testHelper = new XmlWriterTestHelper<JoinMapping>();
            testHelper.Check(x => x.TableName, "tbl").MapsToAttribute("table");

            testHelper.VerifyAll(writer);
        }

        [Test]
        public void ShouldWriteSchemaAttribute()
        {
            var testHelper = new XmlWriterTestHelper<JoinMapping>();
            testHelper.Check(x => x.Schema, "dbo").MapsToAttribute("schema");

            testHelper.VerifyAll(writer);
        }

        [Test]
        public void ShouldWriteFetchAttribute()
        {
            var testHelper = new XmlWriterTestHelper<JoinMapping>();
            testHelper.Check(x => x.Fetch, "fetch").MapsToAttribute("fetch");

            testHelper.VerifyAll(writer);
        }

        [Test]
        public void ShouldWriteInverseAttribute()
        {

            var testHelper = new XmlWriterTestHelper<JoinMapping>();
            testHelper.Check(x => x.Inverse, true).MapsToAttribute("inverse");

            testHelper.VerifyAll(writer);
        }

        [Test]
        public void ShouldWriteOptionalAttribute()
        {
            var testHelper = new XmlWriterTestHelper<JoinMapping>();
            testHelper.Check(x => x.Optional, true).MapsToAttribute("optional");

            testHelper.VerifyAll(writer);
        }


        public bool Equals(JoinMapping other)
        {
            if (ReferenceEquals(null, other)) return false;
            if (ReferenceEquals(this, other)) return true;
            return Equals(other.attributes, attributes) &&
                Equals(other.mappedMembers, mappedMembers) &&
                Equals(other.ContainingEntityType, ContainingEntityType);
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            if (ReferenceEquals(this, obj)) return true;
            if (obj.GetType() != typeof(JoinMapping)) return false;
            return Equals((JoinMapping)obj);
        }

        public void Set<T>(Expression<Func<JoinMapping, T>> expression, int layer, T value)
        {
            Set(expression.ToMember().Name, layer, value);
        }


        public bool HasValue<TResult>(Expression<Func<JoinMapping, TResult>> property)
        {
            return attributes.HasValue(property);
        }

        public void SetDefaultValue<TResult>(Expression<Func<JoinMapping, TResult>> property, TResult value)
        {
            attributes.SetDefault(property, value);
        }


        [SetUp]
        public void GetWriterFromContainer()
        {
            var container = new XmlWriterContainer();
            writer = container.Resolve<IXmlWriter<JoinMapping>>();
        }

        [Test]
        public void ShouldWriteTableAttribute()
        {
            var testHelper = new XmlWriterTestHelper<JoinMapping>();
            testHelper.Check(x => x.TableName, "tbl").MapsToAttribute("table");

            testHelper.VerifyAll(writer);
        }

        [Test]
        public void ShouldWriteSchemaAttribute()
        {
            var testHelper = new XmlWriterTestHelper<JoinMapping>();
            testHelper.Check(x => x.Schema, "dbo").MapsToAttribute("schema");

            testHelper.VerifyAll(writer);
        }

        [Test]
        public void ShouldWriteFetchAttribute()
        {
            var testHelper = new XmlWriterTestHelper<JoinMapping>();
            testHelper.Check(x => x.Fetch, "fetch").MapsToAttribute("fetch");

            testHelper.VerifyAll(writer);
        }

        [Test]
        public void ShouldWriteInverseAttribute()
        {

            var testHelper = new XmlWriterTestHelper<JoinMapping>();
            testHelper.Check(x => x.Inverse, true).MapsToAttribute("inverse");

            testHelper.VerifyAll(writer);
        }

        [Test]
        public void ShouldWriteOptionalAttribute()
        {
            var testHelper = new XmlWriterTestHelper<JoinMapping>();
            testHelper.Check(x => x.Optional, true).MapsToAttribute("optional");

            testHelper.VerifyAll(writer);
        }


		protected void BindClass(IEntityMapping classMapping, PersistentClass model, IDictionary<string, MetaAttribute> inheritedMetas)
		{
			// handle the lazy attribute
			// go ahead and set the lazy here, since pojo.proxy can override it.
			model.IsLazy = classMapping.UseLazy.HasValue ? classMapping.UseLazy.Value : mappings.DefaultLazy;

			// transfer an explicitly defined entity name
			string entityName = classMapping.EntityName ??
								ClassForNameChecked(classMapping.Name, mappings, "persistent class {0} not found").FullName;
			if (entityName == null)
				throw new MappingException("Unable to determine entity name");
			model.EntityName = entityName;

			BindPocoRepresentation(classMapping, model);
			BindXmlRepresentation(classMapping, model);
			BindMapRepresentation(classMapping, model);

			BindPersistentClassCommonValues(classMapping, model, inheritedMetas);
		}

		protected void BindUnionSubclasses(IEnumerable<HbmUnionSubclass> unionSubclasses, PersistentClass persistentClass, IDictionary<string, MetaAttribute> inheritedMetas)
		{
			foreach (var unionSubclass in unionSubclasses)
			{
				new UnionSubclassBinder(this).HandleUnionSubclass(persistentClass, unionSubclass, inheritedMetas);
			}
		}

		protected void BindJoinedSubclasses(IEnumerable<HbmJoinedSubclass> joinedSubclasses, PersistentClass persistentClass, IDictionary<string, MetaAttribute> inheritedMetas)
		{
			foreach (var joinedSubclass in joinedSubclasses)
			{
				new JoinedSubclassBinder(this).HandleJoinedSubclass(persistentClass, joinedSubclass, inheritedMetas);
			}
		}

		protected void BindSubclasses(IEnumerable<HbmSubclass> subclasses, PersistentClass persistentClass, IDictionary<string, MetaAttribute> inheritedMetas)
		{
			foreach (var subclass in subclasses)
			{
				new SubclassBinder(this).HandleSubclass(persistentClass, subclass, inheritedMetas);
			}
		}

		private void BindPersistentClassCommonValues(IEntityMapping classMapping, PersistentClass model, IDictionary<string, MetaAttribute> inheritedMetas)
		{
			// DISCRIMINATOR
			var discriminable = classMapping as IEntityDiscriminableMapping;
			model.DiscriminatorValue = (discriminable == null || string.IsNullOrEmpty(discriminable.DiscriminatorValue)) ? model.EntityName : discriminable.DiscriminatorValue;

			// DYNAMIC UPDATE
			model.DynamicUpdate = classMapping.DynamicUpdate;

			// DYNAMIC INSERT
			model.DynamicInsert = classMapping.DynamicInsert;

			// IMPORT
			// For entities, the EntityName is the key to find a persister
			// NH Different behavior: we are using the association between EntityName and its more certain implementation (AssemblyQualifiedName)
			// Dynamic entities have no class, reverts to EntityName. -AK
			string qualifiedName = model.MappedClass == null ? model.EntityName : model.MappedClass.AssemblyQualifiedName;
			mappings.AddImport(qualifiedName, model.EntityName);
			if (mappings.IsAutoImport && model.EntityName.IndexOf('.') > 0)
				mappings.AddImport(qualifiedName, StringHelper.Unqualify(model.EntityName));

			// BATCH SIZE
			if (classMapping.BatchSize.HasValue)
				model.BatchSize = classMapping.BatchSize.Value;

			// SELECT BEFORE UPDATE
			model.SelectBeforeUpdate = classMapping.SelectBeforeUpdate;

			// META ATTRIBUTES
			model.MetaAttributes = GetMetas(classMapping, inheritedMetas);

			// PERSISTER
			if(!string.IsNullOrEmpty(classMapping.Persister))
				model.EntityPersisterClass = ClassForNameChecked(classMapping.Persister, mappings,
																 "could not instantiate persister class: {0}");

			// CUSTOM SQL
			HandleCustomSQL(classMapping, model);
			if (classMapping.SqlLoader != null)
				model.LoaderName = classMapping.SqlLoader.queryref;

			foreach (var synchronize in classMapping.Synchronize)
			{
				model.AddSynchronizedTable(synchronize.table);
			}

			model.IsAbstract = classMapping.IsAbstract;
		}

		private void BindMapRepresentation(IEntityMapping classMapping, PersistentClass entity)
		{
			HbmTuplizer tuplizer = classMapping.Tuplizers.FirstOrDefault(tp => tp.entitymode == HbmTuplizerEntitymode.DynamicMap);
			if (tuplizer != null)
			{
				string tupClassName = FullQualifiedClassName([email protected], mappings);
				entity.AddTuplizer(EntityMode.Map, tupClassName);
			}
		}


        public void AddProperty(PropertyMapping property)
        {
            mappedMembers.AddProperty(property);
        }

        public void AddReference(ManyToOneMapping manyToOne)
        {
            mappedMembers.AddReference(manyToOne);
        }

        public void AddComponent(IComponentMapping componentMapping)
        {
            mappedMembers.AddComponent(componentMapping);
        }

        public void AddAny(AnyMapping mapping)
        {
            mappedMembers.AddAny(mapping);
        }

        public void AddCollection(CollectionMapping collectionMapping)
        {
            mappedMembers.AddCollection(collectionMapping);
        }

        public void AcceptVisitor(IMappingModelVisitor visitor)
        {
            visitor.ProcessJoin(this);

            if (Key != null)
                visitor.Visit(Key);

            mappedMembers.AcceptVisitor(visitor);
        }

FluentNHibernate.MappingModel.JoinMapping : IMapping

Constructors :

public JoinMapping()
public JoinMapping(AttributeStore attributes = )

Methods :

public KeyMapping get_Key()
public IEnumerable<PropertyMapping> get_Properties()
public IEnumerable<ManyToOneMapping> get_References()
public IEnumerable<IComponentMapping> get_Components()
public IEnumerable<AnyMapping> get_Anys()
public IEnumerable<CollectionMapping> get_Collections()
public Void AddProperty(PropertyMapping property = )
public Void AddReference(ManyToOneMapping manyToOne = )
public Void AddComponent(IComponentMapping componentMapping = )
public Void AddAny(AnyMapping mapping = )
public Void AddCollection(CollectionMapping collectionMapping = )
public Void AddStoredProcedure(StoredProcedureMapping storedProcedureMapping = )
public String get_TableName()
public String get_Schema()
public String get_Catalog()
public String get_Subselect()
public String get_Fetch()
public Boolean get_Inverse()
public Boolean get_Optional()
public Type get_ContainingEntityType()
public Void set_ContainingEntityType(Type value = )
public Void AcceptVisitor(IMappingModelVisitor visitor = )
public Boolean Equals(JoinMapping other = )
public Boolean Equals(Object obj = )
public Int32 GetHashCode()
public Void Set(Expression<Func<JoinMapping, T>> expression = , Int32 layer = , T value = )
public Void Set(String attribute = , Int32 layer = , Object value = )
public Boolean IsSpecified(String attribute = )
public Type GetType()
public String ToString()