How to query filter AnalysisPeriods?

SOLVED

Hi all,

I am able to access analysis periods from StockItem class. However I cannot filter the AnalysisPeriods, lets say Period or Year. There is no Query() function on this class and I cannot use LINQ Where() as well because there is no Period or Year variable to select. For reference see below.

Any suggestion how to do it? Thank you.

  • +1
    verified answer

    It's a transient collection, so it won't have a Query (the collection is hydrated in memory at runtime - it's not mapped to a database table). Also - Sage ObjectStore is older than Linq (ObjectStore has been around since 2002-ish, whereas Linq was only introduced into the .Net runtime around 2007) and as a result the collections don't behave like IQueryable<T> . 

    You need to convert the collection into IEnumerable<SalesTradingAnalysisPeriod>. So you can do something like this:

       si.Holding.TradingAnalysis.SalesAnalysis.AnalysisPeriods
                        .Cast<SalesTradingAnalysisPeriod>()
                        .Where(p => p.CostOfSaleValue > 100M)

  • 0 in reply to Chris Burke

    Thank you Chris. it works.