Hi,
The sql command would be this:
select count(id) from LOTE inner join quadra on lote.id_quadra = quadra.id
where quadra.id_loteamento = 1
Trying to pass to the Aurelius.
function TImobService.TotalLotesPorLoteamento(vId: Integer) : Integer;
begin
result := TXDataOperationContext.Current.GetManager.
Find<TLote>.
CreateAlias('QUADRA', 'Q').
where(Tlinq.eq('q.id_loteamento', vId)).
List.Count;
end;
Has an exception:
Status Code 500
Error Code: PropertyNotFound
Property "Quadra" not found on class "TLOTE".
what am I doing wrong?
wlandgraf
(Wagner Landgraf)
April 18, 2017, 1:56pm
2
I don't know your mapping. You should post your mapping here so we can have an idea of what properties and associations you have. Looks like you don't have a property "Quadra" in your class TLote.
my entity..
[Entity]
[Table('LOTE')]
[Sequence('GEN_LOTE_ID')]
[Id('FID', TIdGenerator.IdentityOrSequence)]
TLOTE = class
private
[Column('ID', [TColumnProp.Required])]
FID: Integer;
[Column('NUMERO', [])]
FNUMERO: Nullable<Integer>;
[Column('COMPRIMENTO', [])]
FCOMPRIMENTO: Nullable<Double>;
[Column('LARGURA', [])]
FLARGURA: Nullable<Double>;
[Column('PRECO_AVISTA', [], 15, 6)]
FPRECO_AVISTA: Nullable<Double>;
[Column('PRECO_PRAZO', [], 15, 6)]
FPRECO_PRAZO: Nullable<Double>;
[Column('ID_CLIENTE', [])]
FID_CLIENTE: Nullable<Integer>;
[Column('STATUS', [], 1)]
FSTATUS: Nullable<string>;
[Association([TAssociationProp.Lazy], CascadeTypeAll - [TCascadeType.Remove])]
[JoinColumn('ID_QUADRA', [], 'ID')]
FID_QUADRA: Proxy<TQUADRA>;
function GetID_QUADRA: TQUADRA;
procedure SetID_QUADRA(const Value: TQUADRA);
public
property ID: Integer read FID write FID;
property NUMERO: Nullable<Integer> read FNUMERO write FNUMERO;
property COMPRIMENTO: Nullable<Double> read FCOMPRIMENTO write FCOMPRIMENTO;
property LARGURA: Nullable<Double> read FLARGURA write FLARGURA;
property PRECO_AVISTA: Nullable<Double> read FPRECO_AVISTA write FPRECO_AVISTA;
property PRECO_PRAZO: Nullable<Double> read FPRECO_PRAZO write FPRECO_PRAZO;
property ID_CLIENTE: Nullable<Integer> read FID_CLIENTE write FID_CLIENTE;
property STATUS: Nullable<string> read FSTATUS write FSTATUS;
property ID_QUADRA: TQUADRA read GetID_QUADRA write SetID_QUADRA;
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], [])]
[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;
wlandgraf
(Wagner Landgraf)
April 18, 2017, 2:12pm
4
Your property name is "ID_QUADRA", not "QUADRA". So you should write it this way:
CreateAlias('ID_QUADRA', 'q')
hi,
Using the AureliusDataSet and a DataSource, carry a dbGrid. However, the ID_LOTEAMENTO field appears a different numbering, I'd like you to appear the field "NOME". The question is, how can I display the DbGrid control the field "NOME" of the Loteamento (Quadra.id_Loteamento.nome)?
ps:"Quero exibir no dbGrid as Quadras e utilizando a associa??o exibir o nome do lotemanto ao inv?s do numero ID do loteamento"
wlandgraf
(Wagner Landgraf)
April 19, 2017, 10:20pm
7