cristianqr
cristianqr

Reputation: 688

How to use linq Sum in a dynamic object

In Data Access Layer I have de following query:

var result = from income in context.Incomes
                join order in context.Orders on income.OrderId equals order.OrderId
                select new
                {
                    Voucher = order.VoucherSeries + "-" + order.VoucherNumber,
                    Amount = income.IncomeAmount
                };
return result.ToList();

In Business layer how to use linq Sum for sum Amount?

Upvotes: 0

Views: 838

Answers (1)

Servy
Servy

Reputation: 203828

Anonymous objects are specifically designed to be used just within the scope in which they are created. If you want to be able to access this data outside of the current scope then you should be creating a new named type that has the two relevant properties that you need, rather than using an anonymous type.

Upvotes: 2

Related Questions