Evaluate Sum Totals

Apr 23, 2010 at 2:52 PM

Thomas,

This may be a very trivial question nveretheless, I have spend some considerable time trying to get it to work.

I have an ExpressionObserver.Execute Statement as below

public IEnumerable<InBoundSummary> OrdersGroupedByMonikers
        {
            get
            {
                return
                    OE.Async(
                            ExpressionObserver.Execute(
                                () =>
                                    (
                                        custOrdersList.Where(p=>loggedUser.Senders.FirstOrDefault(c => c.IsExternal && c.SenderName == p.TAG_142) != null).GroupBy(x => x.Moniker)
                                            .Select(x => new InBoundSummary
                                            {
                                                Moniker = x.First().Moniker,
                                                ExecShares = x.Sum(p => p.ExecSharesCum),
                                                TotalShares = x.Sum(p => p.IsActive ? p.OrdSize : p.ExecSharesCum),
                                                ExecPrice = x.Sum(p => p.ExecSharesCum > 0 ? (p.ExecSharesCum * p.AvgPriceCum) : 0),
                                                TotalPrice = x.Sum(p => p.IsActive ? (p.OrdSize * p.Close) : (p.ExecSharesCum * p.AvgPriceCum)),
                                            }).OrderByDescending(c => c.Moniker)
                                    )
                            ).Cascade()
                        );
            }
        }
All I am trying to do is get the Sum totals for ExecShares, TotalShares, ExecPrice and TotalPrice from OrdersGroupedByMonikers. However, following the following does not generate the result for me.
public IValueProvider<InBoundSummary> OrdersGroupedByMonikersTotal
        {
            get
            {
                return ExpressionObserver.Execute(
                    () =>
                        (
                            new InBoundSummary
                            {
                                ExecShares = OrdersGroupedByMonikers.Sum(p => p.ExecShares),
                                ExecPrice = OrdersGroupedByMonikers.Sum(p => p.ExecPrice),
                                TotalPrice = OrdersGroupedByMonikers.Sum(p => p.TotalPrice),
                                TotalShares = OrdersGroupedByMonikers.Sum(p => p.TotalShares),
                                AvgPrice = 0,
                                TotalArrival = 0,
                                TotalVWAP = 0
                            }
                        ) 
                ).Concrete();
            }
        }
Is this because i am generating a  new InBoundSummary each time.
Thanks
Vinay