Database View with no ID column

I have created a database view which consolidates data in a table using the SUM() aggregate function and a GROUP BY query.  Consequently, the rows returned do not have an ID column (as one row is a summation of multiple rows in the associated table).


When I try to map this view, Aurelius throws an exception (Cannot find mapping [Id] on class Txxxx).

I understand that for tables Aurelius needs an Id column. Is there a way to let Aurelius know that the underlying data is read-only and get it to not require an Id column?

Or can you think of another 'trick' to make this work?

- Niels


The class looks like this:



  [Entity, Automapping]
  [Table('VIEW_CONSOLIDATED_BOOKINGS')]
  TBooking = class( TORMEntity )
  private
    FBOOKING: integer;
    FPROJID: integer;
    FUSERID: integer;
    FSTARTDATE: TDate;
  public
    property STARTDATE: TDate read FSTARTDATE write FSTARTDATE;
    property PROJID: integer read FPROJID write FPROJID;
    property USERID: integer read FUSERID write FUSERID;
    property BOOKING: integer read FBOOKING write FBOOKING;
  end;


All entities require an ID. Among the reasons is the fact that the manager tracks the existing entities to avoid duplicates. So he needs to know what is the ID to detect if the entity is already there.

You can simply choose any field combination that would be unique to your results and set it as the id - even if the id would be all the fields in the class.