I am not able to sort column for NonPersistent column. (DevExpress eXpressApp Framework (XAF) and eXpress Persistent Objects (XPO) ) Here my code
[Association("PCs-Gs", typeof(Allotments))]
public XPCollection<Allotments> PCs
{
get { return GetCollection<Allotments>("PCs"); }
}
[Association("SCs-Gs", typeof(Allotments))]
public XPCollection<Allotments> SCs
{
get { return GetCollection<Allotments>("SCs"); }
}
XPCollection<Allotments> _allAllotmentsCore;
public XPCollection<Allotments> AllAllotments
{
get
{
if (_allAllotmentsCore == null)
{
_allAllotmentsCore = new XPCollection<Allotments>(Session);
}
_allAllotmentsCore.Criteria = CriteriaOperator.Parse("PCGrower.Oid == ? OR SCGrower.Oid == ?", Oid);
_allAllotmentsCore.Sorting.Add(new SortProperty("Project.ProjectName", SortingDirection.Descending));
PopulateCollection(_allAllotmentsCore);
return _allAllotmentsCore;
}
}
private void PopulateCollection(XPCollection<Allotments> sourceCollection)
{
sourceCollection.AddRange(PCs);
sourceCollection.AddRange(SCs);
}
Now properties
[PersistentAlias("PCs[Project is not null].Count")] // THIS IS WORKING
//[PersistentAlias("AllAllotments[PCs.Project is not null].Count")] // THIS IS NOT WORKING
public int myCustomProperties
{
get { return Convert.ToInt32(EvaluateAlias("myCustomProperties")); }
}
IF use PersistentAlias on NonPersistent column then I can able to sort this column. For that, I need to add logic on PersistentAlias.
In My Case:
I need to add this logic on PersistentAlias like [PersistentAlias('whole logic')]
LOgic
public int myCustomProperties
{
get
{
int _myCustomProperties = 0;
Projects project = null;
foreach (Allotments obj in AllAllotments)
{
if (project != obj.Project && obj.Project != null)
{
project = obj.Project;
_myCustomProperties += 1;
}
}
return _myCustomProperties ;
}
}
Let focus on logic
I have use AllAllotments (this not Association properties).
If I use like [PersistentAlias('use AllAllotments')] then I got error.
But I use like [PersistentAlias("use PCs")] then working.
Only different: PCs (Association properties) and AllAllotments (not Association ).
SO, MY Question:
How I can use AllAllotments on PersistentAlias ?
Anyone idea?