0
你好我需要得到兩個集合作爲XpCollections,但「cMemberInfo.GetValue(this)」帶給我類型「DevExpress.Xpo.XPCollection`1」是嗎?可能會以某種方式將其轉換爲 DevExpress.Xpo.XPCollection?將DevExpress.Xpo.XPCollection`1轉換爲DevExpress.Xpo.XPCollection
XPCollection cColl1 = cMemberInfo.GetValue(this) as XPCollection;
XPCollection cColl2 = cMemberInfo.GetValue(cObject) as XPCollection;
作爲不轉換型兩者cColl的結果都爲空
存在其中這些集合被用來
foreach (XPMemberInfo cMemberInfo in ClassInfo.CollectionProperties)
{
XPCollection cColl1 = cMemberInfo.GetValue(this) as XPCollection;
XPCollection cColl2 = cMemberInfo.GetValue(cObject) as XPCollection;
if (cColl1 == null || cColl2 == null) { Debug.Assert(false); return false; }
if (cColl1.Count != cColl2.Count) { return false; }
for (int i = 0; i < cColl1.Count; ++i)
{
XPOBase cObj1 = cColl1[i] as XPOBase;
XPOBase cObj2 = cColl2[i] as XPOBase;
bRet &= cObj1.IsDataEqual(cObj2);
}
}
如果我在XPCollection的情況下使用XPBaseCollection我不能的代碼全部分聲明cColl1 [i]或cColl2 [i]
CI想過類型,但這種方法是使用不同的類型。 我會嘗試使用XPBaseCollection,不適合。 我編輯我的帖子添加了更多的代碼。 – Edgar 2012-08-03 09:09:00
@konopiuxkonopiux您可以使用[XPBaseCollection.BaseIndexer](http://documentation.devexpress.com/#XPO/DevExpressXpoXPBaseCollection_BaseIndexertopic)方法來獲取集合對象。 – Filip 2012-08-03 10:17:14