Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 639643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:51:56+00:00 2026-05-13T20:51:56+00:00

I have two LINQ statements that I would like to make into one, but

  • 0

I have two LINQ statements that I would like to make into one, but for the life of me I can’t get it to work.

I can’t get the grouping to work in the first statement.
It complains that the TotalBuy and TotalSell properties aren’t there, although doesn’t complain about AmountTC and AmountAUD.

This should be simple. Any thoughts?

var itineraryItems =
    from ii in this.ItineraryItemRecords
    join t in this.TransactionRecords on ii.OperatorID equals t.
    TransactionActor.OperatorID into g select new {
    OperatorID = ii.OperatorID, TotalBuy = g.Sum(i = >ii.TotalBuy)
        , TotalSell = g.Sum(i = >ii.TotalSell)
        , PaidTC = (0 - (g.Sum(t = >t.AmountTC)))
        , PaidAUD = (0 - (g.Sum(t = >t.AmountAUD)))
};

var itineraryItemz =
    from i in itineraryItems group i by i.OperatorID into g select new {
    OperatorID = g.Key, TotalBuy = g.Sum(i = >i.TotalBuy)
        , TotalSell = g.Sum(i = >i.TotalSell)
        , PaidTC = (0 - (g.Sum(i = >i.PaidTC)))
        , PaidAUD = (0 - (g.Sum(i = >i.PaidAUD)))
};

As a side note, ItineraryItemRecords and TransactionRecords are Collections of classes handled by SubSonic.

This really should be simple, so any help would be appreciated.

Regards,
John

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T20:51:56+00:00Added an answer on May 13, 2026 at 8:51 pm

    A minor mistake, corrected:

    var itineraryItems = from ii in this.ItineraryItemRecords 
       join t in this.TransactionRecords on ii.OperatorID equals t.TransactionActor.OperatorID 
       into g 
       select new 
       { 
           OperatorID = ii.OperatorID 
           //, TotalBuy = g.Sum(i => ii.TotalBuy) 
           , TotalBuy = g.Sum(i => i.TotalBuy) 
           //, TotalSell = g.Sum(i => ii.TotalSell) 
           , TotalSell = g.Sum(i => i.TotalSell) 
           , PaidTC = (0 - (g.Sum(t => t.AmountTC))) 
           , PaidAUD = (0 - (g.Sum(t => t.AmountAUD))) 
       }; 
    

    I recommend against re-using identifiers – will help avoid these mistakes in the future.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two lists that have been merged. After a order by linq statement,
I would like to execute a Linq to Sql statement that captures the count
I know Linq doesn't have a function that supports FullTextSearch, but my website (which
I have a stored procedure that returns two int Values. The first can not
I have the following linq expression that lets me join two tables, group them
I am using VB.NET with LINQ to MS SQL. I have two following tables.
Have two actionsheet buttons and one modalviewcontroller on mainviewcontroller in application. Now for two
I have two classes (MVC view model) which inherits from one abstract base class.
I have two columns say Main and Sub . (they can be of same
I have a table that has two records (there will be many at runtime).

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.