Link to home
Start Free TrialLog in
Avatar of henry
henry Flag for United States of America

asked on

C# code

Hello,

See below statement & comments:

foreach (var ttQH in (from QH in ttQuoteHed
join QD in Db.QuoteDtl on
new {QH.Company, QH.QuoteNum} equals
new {QD.Company, QD.QuoteNum}
select new{QH, QD.ExtCost_c})) - "Here I need select all records belong to Quote not only new one"

{
ttQH.QH["TotItemCost_c"] = ttQH.ExtCost_c;  - "Here I need show SUM of ExtCost"
}

Have no idea how to do that.

thanks

henry
Avatar of Ioannis Paraskevopoulos
Ioannis Paraskevopoulos
Flag of Greece image

Hi,

Do you need for every Quote the sum of all ExtCost in the Quote details?

May i suggest the following approach:

var quotes = ttQuoteHed
    .GroupJoin
    (
        Db.QuoteDtl,
        QH => new {QH.Company, QH.QuoteNum} ,
        QD => new {QD.Company, QD.QuoteNum} ,
        (h,d) => new {h, sumOfExtraCosts = d.Sum(c=>c.ExtCost_c)}
    )

Open in new window


After the execution of the above, you will have a "list" of objects with 2 properties. The first property will be of type of ttQuoteHed and will have all the columns of that table. The second property will be named sumOfExtraCosts and will have the sum of extra costs for that quote.

Giannis
Avatar of henry

ASKER

Maybe my explanation was not clear enough.
I have a quote with multiple parts on it.
ex: Quote # 1
Part x
Part y
Part z
I will need take value from field "ExtCost_c" belong to each part number, SUM and display in quote header

thanks

henry
ASKER CERTIFIED SOLUTION
Avatar of Ioannis Paraskevopoulos
Ioannis Paraskevopoulos
Flag of Greece image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of henry

ASKER

Working,

thanks