我无法为NonPersistent列排序列。(DevExpress eXpressApp Framework (XAF)和eXpress持久性对象(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")); }
}
如果在PersistentAlias列上使用NonPersistent,那么我可以对该列进行排序。为此,我需要在PersistentAlias上添加逻辑。
就我而言:
我需要在PersistentAlias上添加这个逻辑,比如PersistentAlias(‘整个逻辑’)
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(‘使用AllAllotments'),那么我得到错误。
但我使用像PersistentAlias(“使用个人电脑”)然后工作。
只是不同:PC(关联属性)和AllAllotments (非关联)。
所以,我的问题是:
如何在AllAllotments上使用PersistentAlias?
有人知道吗?
发布于 2016-09-06 15:58:58
你可以使用一个免费的连接。来自DevExpress文档。
使用XPO,您可以使用Free构建基于不直接相关(没有显式定义的关联)的持久对象的标准。本质上,XPO允许您在一个条件下连接任何持久对象,使用它们的属性根据匹配的对象计算聚合函数,并作为连接的结果返回聚合值。要做到这一点,请在标准中使用JoinOperands。
您可以在标准中使用它们,例如,
CriteriaOperator criteria =
CriteriaOperator.Parse("[<Orders>][^.EmployeeID = EmployeeID].Count() > 50");
XPCollection<Employee> employees = new XPCollection<Employee>(session, criteria);
或者您可以在[PersistentAlias]
中使用它们。见此项目来自DevExpress支持中心。
public class Department : BaseObject
{
private System.Int32? _TotalPhoneNumbers;
[PersistentAlias("[<PhoneNumber>][Party.<Contact>Department.Oid = ^.Oid and PhoneType='1'].Count()")]
public System.Int32? TotalPhoneNumbers {
get {
if (_TotalPhoneNumbers == null) {
_TotalPhoneNumbers = (int?)EvaluateAlias("TotalPhoneNumbers");
}
return _TotalPhoneNumbers;
}
}
}
对于所有的事情,DevExpress,最好的地方是问他们的支援中心。
https://stackoverflow.com/questions/39250403
复制相似问题