Help with Mapping

Hi,

I have two entities:


 [Entity]  [Table('LOTEAMENTO')]  [Sequence('GEN_LOTEAMENTO_ID')]  [Id('FID', TIdGenerator.IdentityOrSequence)]  TLOTEAMENTO = class  private    [Column('ID', [TColumnProp.Required])]    FID: Integer;        [Column('NOME', [], 100)]    FNOME: Nullable<string>;  public    property ID: Integer read FID write FID;    property NOME: Nullable<string> read FNOME write FNOME;    end;



[Entity]
  [Table('QUADRA')]
  [Sequence('GEN_QUADRA_ID')]
  [Id('FID', TIdGenerator.IdentityOrSequence)]
  TQUADRA = class
  private
    [Column('ID', [TColumnProp.Required])]
    FID: Integer;
    
    [Column('NOME', [], 50)]
    FNOME: Nullable<string>;
    
   [Association([TAssociationProp.Lazy],CascadeTypeAll - [TCascadeType.Remove])]
    [JoinColumn('ID_LOTEAMENTO', [], 'ID')]
    FID_LOTEAMENTO: Proxy<TLOTEAMENTO>;
    function GetID_LOTEAMENTO: TLOTEAMENTO;
    procedure SetID_LOTEAMENTO(const Value: TLOTEAMENTO);
  public
    property ID: Integer read FID write FID;
    property NOME: Nullable<string> read FNOME write FNOME;
    property ID_LOTEAMENTO: TLOTEAMENTO read GetID_LOTEAMENTO write SetID_LOTEAMENTO;
  end;


How should that entity be mapped to when adding a <Tquadra> also does not insert a <TLoteamento>?

Thanks,

When saving TQuadra, if you just do not set ID_LOTEAMENTO property (if the property is nil) then it will not include any TLoteamento in the database. It's not sure to me if that was your question?

well,



I have a form that registers the "Loteamento". When I am inserting a "Quadra" automatically insert a "Loteamento", I do not want this to happen.


var  Lotea : TLoteamento;  Qdr    : TQuadra;begin  Lotea      := TLoteamento.Create;  Lotea.NOME := cbLoteamento.text;  Qdr.NOME          := edtNome.Text;  Qdr.ID_LOTEAMENTO := Lotea;  AQuadra.Put(Qdr);


The classes were created by TMS Data Modeler from my bank. There is a foreign key between "Loteamento" and (1: n) to "Quadra". One for many. How can I set the TQuadra class to prevent this cascade from always inserting a Plot when I'm entering or changing a block.

Thank's...

Remove TCascade.SaveUpdate from cascade:


CascadeTypeAll - [TCascadeType.SaveUpdate, TCascadeType.Remove])