无法隐式转换类型'DevExpress.Xpo.XPCollection'

时间:2014-08-11 15:45:56

标签: c# devexpress xaf objectspace

我正在尝试创建一个返回类似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>'

1 个答案:

答案 0 :(得分:0)

以下示例是我如何创建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;
        }
    }