Property not Found with Linq query - Observation

When I run the following code in my XData server

LJobsList := Manager.Find<TJob>.Where(TLinq.eq('Status', TJobStatus.New) or TLinq.eq('Status', TJobStatus.Queued)
        or TLinq.eq('Status', TJobStatus.Processing)).List;

I get an exception

Property "Status" not found on class "TJob"

The entity TJob.Status is defined as

  TJob = class
  private
    [Column('JOBSTATUS')]
    FJobStatus: TJobStatus;
  public
    property Status: TJobStatus read FJobStatus write FJobStatus;
  end;

However, if I define the property like this:

  TJob = class
  private
    [Column('JOBSTATUS')]
    FStatus: TJobStatus;
  public
    property Status: TJobStatus read FStatus write FStatus;
  end;

then the selection works. So it is not the property it is looking for but the field. Is that correct?

1 Like

Yes. It looks for the [mapped] field.

1 Like

Correct. Aurelius queries only know about mapped members. However, It does recognize field names without the leading "F" so you don't need to add it all the time and the names of fields would look like they are properties.

Maybe useful if the error message reflected that.

Not sure how the error message can be improved, without looking like a "documentation"? The property tried didn't exist, that's the error. Regardless if it's Status or asdjkfakjshdf.

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