Habanero.BO.ClassDefinition.SingleRelationshipDef.SetAsOneToOne C# (CSharp) Method

SetAsOneToOne() public method

Sets this SingleRelationshipDef as a One To One. This overrides the default of it being set to ManyToOne. This is used by the Reflective ClassDefLoaders in Habanero.Smooth to load ClassDefinitions based on the BusinessObject.
public SetAsOneToOne ( ) : void
return void
        public void SetAsOneToOne()
        {
            _setAsOneToOne = true;
        }

Usage Example

        /// <summary>
        /// Maps the <see cref="ReflectionWrappers.PropertyWrapper"/> to a <see cref="IRelationshipDef"/>.
        /// </summary>
        /// <returns></returns>
        public IRelationshipDef MapOneToOne()
        {
            if (!MustBeMapped()) return null;
            CheckReverseRelationshipValid();
            
            var relatedClassType = PropertyWrapper.RelatedClassType.UnderlyingType;
            DeleteParentAction deleteAction = GetDeleteAction();

            var relDef = new SingleRelationshipDef(this.PropertyWrapper.Name, relatedClassType
                                            , new RelKeyDef(), true, deleteAction)
                      {
                          OwningBOHasForeignKey = this.OwningBoHasForeignKey,
                          ReverseRelationshipName = this.ReverseRelationshipName
                      };
            SetRelationshipType(relDef);
            relDef.SetAsOneToOne();
            IRelPropDef relPropDef = this.CreateRelPropDef();
            relDef.RelKeyDef.Add(relPropDef);
            return relDef;
        }