Cannot implicitly convert type 'DevExpress.Xpo.XPCollection'

2k views Asked by At

I am trying to create a procedure which return an XPcollection like so:

    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;
        }

    }

but I am getting the error below:

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

There are 1 answers

2
Shwabster On

The below example is how i create XPCollections, i hope it can help!

    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;
        }
    }