FindColumn by Column-Name

For this:

csCustFldMain = 'MainId';

  [Entity]
  TEntityCustFld = class(TBaseCustFld)
  private
    [JoinColumn(csCustFldMain, [TColumnProp.Unique, TColumnProp.Required])]
    FParentEntity: Proxy<TParentEntity>;
...
  public
    ParentEntity: TParentEntity;
...

It does not work to query the Data by using:

Find<TEntityCustFld>.Where(Linq[csCustFldMain] = someValue).UniqueResult;

That's what I expected from the documents

Linq[<propertyname>]

Note that in all the methods listed here, the method can receive a string (representing a property name) or a projection. See TProjections.Prop for more details.

But stepping into the EPropertyNotFound-Error I get, I think it might be possible, if
TMappingExplorer.FindColumnByPropertyName
would find Optimizations by C.Name

so if you would change:

  for C in EntityType.AllColumns do
    if SameText(C.Optimization.MemberName, PropName) then
      Exit(C);

to

  for C in EntityType.AllColumns do
    if SameText(C.Optimization.MemberName, PropName) or SameText(C.Name, PropName) then
      Exit(C);

and also for // If not found, find fields ...
It could work for declared Names by using Column, JoinColumn, ... Attribute.

As an ORM, Aurelius abstracts the underlying database and allows the user to work with the objects. So it doesn't make much sense to use the "low-level" column names as if they were properties of the object. Conceptually, you are querying objects, not tables.

But you can achieve what you want this way:

Find<TEntityCustFld>
  .Where(Linq.Sql<Integer>('A.MainId = ?'), someValue)
  .UniqueResult;

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