Property not found

Hi!


I have a strange error and I need some help, because i've tried all and have no ideas :(

Class

  [Entity]
  [Table('type_partner')]
  [Id('FParName', TIdGenerator.None)]
  TPartnerType = class
  private
    [Column('NAME', [TColumnProp.Required], 20)]
    FParName: string;
    [Column('PAR_TYPE', [], 45)]
    FParType: string;
  public
    property TypeName: string read FParName write FParName;
    property TypeType: string read FParType write FParType;
  end;


DB fields do match in all (type and size) to the class definition.

Code that works:

  FManager := TAureliusManager.Create(self);
  FManager.Connection := aurConnection;
  itm := FManager.Find<TPartnerType>().Take(1).UniqueResult;
  ShowMEssage(itm.TypeType);


This shows a dialog with the expected text.

Code that is not working:

  FManager := TAureliusManager.Create(self);
  FManager.Connection := aurConnection;
  itm := FManager.Find<TPartnerType>().Where(Linq['TypeType'] = 'SUPPLIER').Take(1).UniqueResult;
  ShowMEssage(itm.TypeType);


Error: 
---------------------------
Debugger Exception Notification
---------------------------
Project Easy.exe raised exception class EPropertyNotFound with message 'Property "TypeType" not found on class "TPartnerType".'.
---------------------------
Break   Continue   Help   
---------------------------

Stack:

exception class    : EPropertyNotFound
exception message  : Property "TypeType" not found on class "TPartnerType".


main thread ($2a0c):
015e6665 +04d Easy.exe     Aurelius.Mapping.Explorer               TMappingExplorer.GetColumnByPropertyName
0157fcd1 +049 Easy.exe     Aurelius.Commands.Selecter              TSelecter.TCriteriaSolver.GetPropertySqlExpression
0154249a +046 Easy.exe     Aurelius.Criteria.Base                  TPropertyProjection.BuildSql
01540228 +050 Easy.exe     Aurelius.Criteria.Base                  TSimpleExpression.BuildSql
01541801 +081 Easy.exe     Aurelius.Criteria.Base                  TCriteriaBuilder.AppendExpressions
01541a66 +05a Easy.exe     Aurelius.Criteria.Base                  TCriteriaBuilder.GetConditionalStatement
01541d30 +010 Easy.exe     Aurelius.Criteria.Base                  TCriteriaBuilder.GetWhereStatement
0157d4fe +0d2 Easy.exe     Aurelius.Commands.Selecter              TSelecter.BuildCommand
0157e49f +04b Easy.exe     Aurelius.Commands.Selecter              TSelecter.ExecuteSelectSome
0157f5d4 +06c Easy.exe     Aurelius.Commands.Selecter              TSelecter.SelectBegin
015aae30 +068 Easy.exe     Aurelius.Engine.ObjectManager           TObjectManager.TEngineCursor.Create
015a9535 +00d Easy.exe     Aurelius.Engine.ObjectManager           TObjectManager.Open
01540a38 +014 Easy.exe     Aurelius.Criteria.Base                  TCriteria.DoOpen
01540a49 +009 Easy.exe     Aurelius.Criteria.Base                  TCriteria.FillList
01a85234 +040 Easy.exe     PartnerMngr                      39  +0 TCriteria.UniqueResult<Partner.TPartnerType>
01a84528 +000 Easy.exe     PartnerMngr                      39  +0 {Aurelius.Criteria.Base}TCriteria<Partner.TPartnerType>.UniqueResult
0072e31d +031 Easy.exe     Vcl.Forms                               TCustomForm.DoCreate
0072de7d +14d Easy.exe     Vcl.Forms                               TCustomForm.Create
0127bf41 +0a5 Easy.exe     AdvToolBar                    55744 +11 TAdvToolBarForm.Create
0040f5f4 +20c Easy.exe     System                           80  +0 DynArraySetLength
0073956e +076 Easy.exe     Vcl.Forms                               TApplication.CreateForm
01f11e51 +045 Easy.exe     Easy                            295  +4 initialization
749f0417 +017 KERNEL32.DLL                                         BaseThreadInitThunk



I don't understand why aurelius can display a property in a dialog, but cannot use it in a query.

Added DB table definition



CREATE TABLE `type_partner` (
	`NAME` VARCHAR(20) NOT NULL,
	`PAR_TYPE` VARCHAR(45),
	PRIMARY KEY (`NAME`)
);

Your mapping is:


Mapped class members are FParName and FParType. That's all Aurelius know about. For readability purposes, Aurelius access you refer to those mapped members as FParName/FParType, or ParName/ParType (removing leading "F" from class field names).

TypeName and TypeType are not known by Aurelius. Usually it "looks" like Aurelius deals with properties because properties are declared with the same name as the fields, without the "F". Then it works and it looks like Aurelius is reading the property. But it's actually always referring to fields.

It doesn't work in your case because the property name is totally different from the field name.
In summary, you should build your query this way:

itm := FManager.Find<TPartnerType>().Where(Linq['ParType'] = 'SUPPLIER').Take(1).UniqueResult;


You're right - I automatically concluded that I should use public properties.. My mistaek and thank you.