public virtual long GetNewValue(Net.Vpc.Upa.Field field) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { Net.Vpc.Upa.Entity entity = field.GetEntity(); Net.Vpc.Upa.Expressions.Select s = new Net.Vpc.Upa.Expressions.Select().From(entity.GetName()); s.Field(new Net.Vpc.Upa.Expressions.Plus(new Net.Vpc.Upa.Expressions.Coalesce(new Net.Vpc.Upa.Expressions.Max(new Net.Vpc.Upa.Expressions.Var(field.GetName())), new Net.Vpc.Upa.Expressions.Literal(0)), new Net.Vpc.Upa.Expressions.Literal(1)), "next"); Net.Vpc.Upa.Record next = field.GetPersistenceUnit().CreateQuery(s).GetRecord(); if (next != null) { return(next.GetLong("next")); } else { return(0); } }
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); } }