devexpressxafxpo

Complex rule for XPO class


I want to accomplish a simple rule for an XPO class.

The situation is as : - I have a Vehicle class :

public class Vehicle : BaseObject
{
    public Vehicle(Session session)
        : base(session)
    {
    }
    public override void AfterConstruction()
    {
        base.AfterConstruction();
    }

    //...properties

    [Association, DevExpress.Xpo.Aggregated]
    public XPCollection<MeterEntry> MeterEntries
    {
        get { return GetCollection<MeterEntry>("MeterEntries"); }
    }

}

I tried this Rule:

RuleCriteria("MeterValue >= Vehicle.MeterEntries[Date <=  xxx ].Max(MeterValue)")]

In the xxx I want the value of the current object's Date smtng like : TargetObject.Date but it doesn't work, any ideas ?


Solution

  • You need to use the ^ character.

    RuleCriteria("MeterValue >= Vehicle.MeterEntries[Date <= ^.^.Date].Max(MeterValue)")]
    

    See more about Parent Relationship Traversal Operator at: https://documentation.devexpress.com/#CoreLibraries/CustomDocument4928