private bool ProcessRelation(bool throwErrors)
 {
     if (!Build(throwErrors))
     {
         return(false);
     }
     Net.Vpc.Upa.PersistenceUnit pu = sourceEntity.GetPersistenceUnit();
     if (relation == null)
     {
         Net.Vpc.Upa.DefaultRelationshipDescriptor rd = new Net.Vpc.Upa.DefaultRelationshipDescriptor();
         rd.SetName(relationDescriptor.GetName());
         rd.SetBaseField(relationDescriptor.GetBaseField());
         rd.SetRelationshipType(relationDescriptor.GetRelationshipType());
         rd.SetSourceEntity(sourceEntity.GetName());
         rd.SetTargetEntity(targetEntity.GetName());
         rd.SetSourceFields(sourceFieldNames.ToArray());
         rd.SetFilter(relationDescriptor.GetFilter());
         rd.SetHierarchy(relationDescriptor.IsHierarchy());
         rd.SetHierarchyPathField(relationDescriptor.GetHierarchyPathField());
         rd.SetHierarchyPathSeparator(relationDescriptor.GetHierarchyPathSeparator());
         rd.SetNullable(relationDescriptor.IsNullable());
         relation = ((Net.Vpc.Upa.Impl.DefaultPersistenceUnit)pu).AddRelationshipImmediate(rd);
     }
     else
     {
         if (!Net.Vpc.Upa.Impl.Util.StringUtils.IsNullOrEmpty(relationDescriptor.GetName()))
         {
             relation.SetName(relationDescriptor.GetName());
         }
         relation.SetRelationshipType(relationDescriptor.GetRelationshipType() == default(Net.Vpc.Upa.RelationshipType) ? Net.Vpc.Upa.RelationshipType.DEFAULT : relationDescriptor.GetRelationshipType());
         relation.GetSourceRole().SetEntityField(manyToOneField);
         relation.GetSourceRole().SetRelationshipUpdateType(sourceUpdateType);
         System.Collections.Generic.IList <Net.Vpc.Upa.Field> slaveFields = new System.Collections.Generic.List <Net.Vpc.Upa.Field>();
         foreach (string n in sourceFieldNames)
         {
             Net.Vpc.Upa.Field f = sourceEntity.GetField(n);
             slaveFields.Add(f);
         }
         relation.GetSourceRole().SetFields(slaveFields.ToArray());
         relation.GetTargetRole().SetEntityField(null);
         relation.GetTargetRole().SetRelationshipUpdateType(Net.Vpc.Upa.Impl.Util.PlatformUtils.GetUndefinedValue <Net.Vpc.Upa.RelationshipUpdateType>(typeof(Net.Vpc.Upa.RelationshipUpdateType)));
         relation.SetFilter(filter);
         relation.SetNullable(nullable);
     }
     return(true);
 }
 private void BindRelation(Net.Vpc.Upa.Entity masterEntity)
 {
     Net.Vpc.Upa.Types.DataType dataType = field.GetDataType();
     if (dataType is Net.Vpc.Upa.Impl.SerializableOrManyToOneType)
     {
         field.SetDataType(new Net.Vpc.Upa.Types.ManyToOneType(dataType.GetName(), dataType.GetPlatformType(), masterEntity.GetName(), true, dataType.IsNullable()));
         field.SetTypeTransform(null);
         field.SetTypeTransform(new Net.Vpc.Upa.Impl.Transform.IdentityDataTypeTransform(field.GetDataType()));
         Net.Vpc.Upa.DefaultRelationshipDescriptor relationDescriptor = new Net.Vpc.Upa.DefaultRelationshipDescriptor();
         relationDescriptor.SetBaseField(field.GetName());
         relationDescriptor.SetTargetEntityType(masterEntity.GetEntityType());
         relationDescriptor.SetTargetEntity(masterEntity.GetName());
         relationDescriptor.SetSourceEntityType(field.GetEntity().GetEntityType());
         relationDescriptor.SetSourceEntity(field.GetEntity().GetName());
         field.GetPersistenceUnit().AddRelationship(relationDescriptor);
     }
 }