我无法为 NonPersistent 列排序。(DevExpress eXpressApp Framework (XAF) 和 eXpress Persistent Objects (XPO))这是我的代码
[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);
}
现在属性
[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")); }
}
如果在 NonPersistent 列上使用 PersistentAlias,那么我可以对该列进行排序。为此,我需要在 PersistentAlias 上添加逻辑。
在我的情况下:
我需要在 PersistentAlias 上添加这个逻辑,例如 [PersistentAlias('whole 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 ;
}
}
让我们专注于逻辑
我使用了 AllAllotments(这不是关联属性)。
如果我使用 [PersistentAlias('use AllAllotments')] 之类的方法,则会出现错误。
但我像 [PersistentAlias("use PCs")] 使用然后工作。
唯一不同的是:PCs(Association 属性)和 AllAllotments(不是 Association)。
所以,我的问题:
如何在 PersistentAlias 上使用 AllAllotments ?
有人知道吗?