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 784425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T20:42:42+00:00 2026-05-14T20:42:42+00:00

Given the following information, how can I combine these 2 linq queries into 1.

  • 0

Given the following information, how can I combine these 2 linq queries into 1. Having a bit of trouble with the join statement.

‘projectDetails’ is just a list of ProjectDetails
ProjectDetails (1 to many) PCardAuthorizations
ProjectDetails (1 to many) ExpenditureDetails

Notice I am grouping by the same information and selecting the same type of information

var pCardAccount =  from c in PCardAuthorizations
                    where projectDetails.Contains(c.ProjectDetail)
                        && c.RequestStatusId == 2 
                    group c by new { c.ProjectDetail, c.ProgramFund } into g

                    select new { Key = g.Key, Sum = g.Sum(x => x.Amount) };



var expenditures =  from d in ExpenditureDetails
                    where projectDetails.Contains(d.ProjectDetails)
                        && d.Expenditures.ExpenditureTypeEnum == 0
                    group d by new { d.ProjectDetails, d.ProgramFunds } into g
                    select new {
                        Key = g.Key,
                        Sum = g.Sum(y => y.ExpenditureAmounts.FirstOrDefault(a => a.IsCurrent && !a.RequiresAudit).CommittedMonthlyRecords.ProjectedEac)
                    };
  • 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-14T20:42:42+00:00Added an answer on May 14, 2026 at 8:42 pm

    I don’t think Mike’s suggestion will work here. These two queries are sufficiently different that combining them into one query will just make it more difficult to read.

    • The objects have different types.
    • The where clauses are different.
    • The group by clause is different:
      • new { c.ProjectDetail, c.ProgramFund }
      • new { c.ProjectDetails, c.ProgramFunds }
    • The select clauses are different.

    In fact there isn’t really anything that is the same. I’d recommend leaving it as it is.

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

Sidebar

Related Questions

Given the following information, how can I select the most recent line items (based
I'm having trouble wrapping my mind around developing this SQL query. Given the following
Given the following information Public Enum Request As Byte None = 0 Identity =
You are given the following information, but you may prefer to do some research
I have the following scenarios: Scenario: Create a game with valid information Given I
I'm trying to determine whether Object1 will collide with Object2 given the following information:
Can someone direct me to some information about how to do the following: I
given the following information I have in a database table: Col 1, Col2, Col3
How should I interpret the output given by GCC's -fmem-report flag? What information can
Using the following SQL, the DDL for a given materialized view can be obtained.

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.