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"); }
}
}
And a MeterEntry class :
public class MeterEntry : BaseObject { public MeterEntry(Session session) : base(session) { } public override void AfterConstruction() { base.AfterConstruction(); }
private int _MeterValue;
private DateTime _Date;
public int MeterValue
{
get
{
return _MeterValue;
}
set
{
SetPropertyValue("MeterValue", ref _MeterValue, value);
}
}
public DateTime Date
{
get
{
return _Date;
}
set
{
SetPropertyValue("Date", ref _Date, value);
}
}
[Association]
public Vehicle Vehicle { get; set; }
}
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 ?
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