E10, BPM, Finding Last Record

Thank you Brenda.


Worked like a charm!

On E9 I would use the code:


Find Last Part where.....


for E10 you would think the code would be:

select Part_Row).LastOrDefault();


however, LastOrDefault is not supported.

The Epicor code convertor tells you to do this:


// TODO: LastOrDefault() is not supported. Convert this to FirstOrDefault(). Make sure you specify an
// order by clause that specifies all the key fields in the opposite order so that the first row
// is the last row that would have been retrieved.



How do you specify the order of the fields?



Here is a template I use:

 

var XXX_Recs = (from XXX_Row in Db.XXX

                where XXX_Row.Company == Session.CompanyID

                && XXX_Row.YYY == ZZZ_Recs.YYY

    orderby XXX_Row.YYY, XXX_Row.YYY

                select XXX_Row).FirstOrDefault();

{

            var XXXRow = XXX_Recs;

            if (XXX_Recs != null)

            {

               callContextBpmData.CCC = XXX_Recs.YYY;

            }

}          /*** XXX ***/

 

 

Brenda

 

From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com]
Sent: Wednesday, February 03, 2016 11:19 AM
To: vantage@yahoogroups.com
Subject: [Vantage] E10, BPM, Finding Last Record

 

 

On E9 I would use the code:

 

Find Last Part where.....

 

for E10 you would think the code would be:

select Part_Row).LastOrDefault();

 

however, LastOrDefault is not supported.

The Epicor code convertor tells you to do this:

 

// TODO: LastOrDefault() is not supported. Convert this to FirstOrDefault(). Make sure you specify an
// order by clause that specifies all the key fields in the opposite order so that the first row
// is the last row that would have been retrieved.

 

 

How do you specify the order of the fields?