I'm trying to make a generic function that returns the maximum code for a table (customer, product, etc.). In SQL I would pass the name of the table directly in the query string, I would like to know if you can do this in aurelius in a generic way (using aurelius entities).
function GetMaxCode(EntityClass: TClass): Integer;
var
Value: TCriteriaResult;
begin
Value := Manager.Find(MyEntityClass)
.Select(Linq['Code'].Max)
.UniqueValue;
Result := Value.Values[0];
Value.Free;
end;
MaxInvoiceCode := GetMaxCode(TInvoice);
MaxCustomerCode := GetMaxCode(TCustomer);