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

  • Home
  • SEARCH
  • 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 7043357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:16:46+00:00 2026-05-28T02:16:46+00:00

I have the below, which has worked fine until I added the last part:

  • 0

I have the below, which has worked fine until I added the last part:

var FbtTotals = from ff in ExpenseItemFbtItems
                group ff by ff.ERLineID into g
                select new { 
                    lineId = g.Key, totalAttendees = g.Sum(
                    m => m.Num_Attendees_In_Group), 
                    attendeeTypes = g.Count(), 
                    purposeDesc = g.FirstOrDefault(n => n.User_Purpose_Description) 
                };

The purposeDesc fails, saying it is an unknown error. Functionally, I just want to do the same thing I did with the ‘sum’ of totalAttendees – but I just want the first element rather than an aggregation.

What have I overlooked?

  • 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-28T02:16:46+00:00Added an answer on May 28, 2026 at 2:16 am

    I’m assuming you’re using an ORM in conjunction with LINQ (EF, NHibernate, LINQ to SQL, etc.). The ORM’s don’t support windowing functions on sets (which is what would be required in order to translate your query); they only support aggregates.

    In order to do what you want, you will have to retrieve all of the records in your query then construct your final object (getting the first item) in client code. Given that you don’t seem to be filtering on anything, you can try this:

    var FbtTotals = from ff in ExpenseItemFbtItems.AsEnumerable()
                                group ff by ff.ERLineID into g
                 select new { lineId = g.Key, totalAttendees = g.Sum(m => m.Num_Attendees_In_Group), attendeeTypes = g.Count(), purposeDesc = g.FirstOrDefault(n => n.User_Purpose_Description) };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a an app which has worked perfectly well until the release of
I have a string which has the below content String msg = The variables
I have an XML file which has many section like the one below: <Operations>
I have a select box which has more than 200 items. Below the select
I have the following mapping in my Castle Windsor xml file which has worked
I have a LINQ query which has the below joins join v in dc.Vehicles
I have the below method which is meant to append information to a file
I have the following listbox below which binds to a database table of image
I have below is the html code for TD which gets appended after matching
I have a list of items (blue nodes below) which are categorized by the

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.