不能隐式转换类型'DevExpress.Xpo.XPCollection'

本文关键字:DevExpress Xpo XPCollection 类型 不能 转换 | 更新日期: 2023-09-27 18:17:33

我正在尝试创建一个返回XPcollection的过程,如下所示:

    public XPCollection<Txn> RetrieveTransactions()
    {
        if (ObjectSpace is DevExpress.ExpressApp.Xpo.XPObjectSpace)
        {
            XPCollection txns = (XPCollection)ObjectSpace.CreateCollection(typeof(Txn));
            if (txns.Count == 0)
            {
            }
            return (XPCollection<Txn>)txns;
        }
    }

但是我得到下面的错误:

    Error   1   Cannot implicitly convert type 'DevExpress.Xpo.XPCollection' to 'DevExpress.Xpo.XPCollection<FX.Module.BusinessObjects.fxdb.Txn>'

不能隐式转换类型'DevExpress.Xpo.XPCollection'

下面的例子是我如何创建XPCollections,我希望它能帮助!

    private XPCollection<Txn> retrieveTransactions;
    public XPCollection<Txn> RetrieveTransactions
    {
        get
        {
            if (ObjectSpace is DevExpress.ExpressApp.Xpo.XPObjectSpace)
            {
                this.retrieveTransactions = new XPCollection<Txn>(Session);
            }
            return this.retrieveTransactions;
        }
    }