Linq and Fieldnames containing '_'

Hey,

i want do filter my Data using the Following code:

  adKanban.ObjectClass:=TKanban;
  adKanban.SetSourceList(dmMain.MainXDClient.List<TKanban>(
        CreateQuery.From(TKanban)
      .Filter(Linq['Art_nr']='f76db3be-8ae9-42e3-81f2-9ed116f4aa34')
      .QueryString
      ));
  adKanban.Open;

Here part of the Entity:

  [Entity]
  [Table('Kanban')]
  [Id('Fnr', TIdGenerator.Guid)]
  TKanban = class
  private
    [Column('nr', [TColumnProp.Required])]
    Fnr: TGuid;
    
    [Column('Title', [], 15)]
    FTitle: Nullable<string>;
    
    [Column('Text', [], 150)]
    FText: Nullable<string>;
    
    [Column('Spalte', [])]
    FSpalte: Nullable<Integer>;
    
    [Column('Eingangsdatum', [])]
    FEingangsdatum: Nullable<TDateTime>;
    
    [Column('Fertigstellungsdatum', [])]
    FFertigstellungsdatum: Nullable<TDateTime>;
    
    [Association([TAssociationProp.Lazy], CascadeTypeAll - [TCascadeType.Remove])]
    [JoinColumn('Art_nr', [], 'nr')]
    FArt_nr: Proxy<TArt>;

When i open the adKanban with the filter expression, i receive the Error "Cannot query property of type 'Art'".
When i filter for fieldnames without "" everything works fine.
How can i filter after fieldnames with "
" ?

Kind regards,

I don't this it relates to the _ in field names, but to the fact that Art_nr is an association, not a primitive property. You should do something like this:

  adKanban.ObjectClass:=TKanban;
  adKanban.SetSourceList(dmMain.MainXDClient.List<TKanban>(
        CreateQuery.From(TKanban)
      .Filter(Linq['Art_nr.id']='f76db3be-8ae9-42e3-81f2-9ed116f4aa34')
      .QueryString
      ));
  adKanban.Open;

(note: the id property of TArt object was guessed, as you did not provide its mapping).

Thanks again. Now it works.

Kind regards,

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.