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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:17:47+00:00 2026-05-17T18:17:47+00:00

I am having trouble getting an IQueryable list of a (subsonic) object grouped by

  • 0

I am having trouble getting an IQueryable list of a (subsonic) object grouped by Month and Year.

Basic view of the object…

public partial class DatabaseObject
{
    [SubSonicPrimaryKey]
    public int objectID { get; set; }

    public string Description { get; set; }

    public decimal Value { get; set; }

    public string Category { get; set; }

    public DateTime DateOccurred { get; set; }
}

Method to get IQueryable in my Database repository…

public IQueryable GetData(string DataType)
{
   return (from t in db.All<DatabaseObject>()
           orderby t.DateOccurred descending
           select t)
          .Where(e => e.Category == DataType);  
}

My question is, how can I return the dates grouped by Month? I have tried the below, but this results in compiler warnings regarding anonymous types…

public IQueryable GetData(string DataType)
{
   var datalist = (from t in db.All<FinancialTransaction>().Where(e => e.Category == DataType);
                   let m = new
                   {
                       month = t.DateOccurred.Month,
                       year = t.DateOccurred.Year
                   }
                   group t by m into l select new
                   {
                       Description = string.Format("{0}/{1}", l.Key.month, l.Key.year),
                       Value = l.Sum(v => v.Value), // Sum(v => v.Value),
                       Category = "Grouped"
                       DateOccurred = l.Last(v => v.DateOccurred)
                   }
    return datalist;
}

Any ideas?

  • 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-17T18:17:47+00:00Added an answer on May 17, 2026 at 6:17 pm

    Try this couple issues i found, but you basically need to select a Database object versus anonymous type?

    IQueryable<DatabaseObject> datalist = (
    from t in db.All<FinancialTransaction>().Where(e => e.Category == DataType)
    let m = new
    {
        month = t.DateOccurred.Month,
        year = t.DateOccurred.Year
    }
    group t by m into l 
    select new DatabaseObject()
    {
        Description = string.Format("{0}/{1}", l.Key.month, l.Key.year),
        Value = l.Sum(v => v.Value),   //Sum(v => v.Value),
        Category = "Grouped", 
        DateOccurred = l.Max(v => v.DateOccurred)
    }).AsQueryable();
    

    Let me know if my solution is now what you want. I also noticed you were using Last? The extension you were using I do not have so I replaced it with Max. I don’t have subsonic installed so it might come with the libraries.

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

Sidebar

Related Questions

Having trouble getting fancybox to display my image correctly, I use ASP.NET: <a class=fancybox
I'm having trouble getting my head around sending multiple models to a view in
I am having trouble getting the text to center inside of a list item.
im having trouble getting a string (containing a URL) from one activity to another.
Im having trouble getting my JTable that im using to display either check boxes
I'm having trouble getting the CanExecute method of my command to work property. I've
I'm having trouble getting Tire working using ElasticSearch with the Bonsai addon on the
I'm currently having trouble getting example code for using tweepy to access Twitter's Streaming
I'm having trouble getting Japanese text to display properly on a website compiled using
I'm having trouble getting the server to recognize a JSON POST request since I

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.