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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T02:37:25+00:00 2026-06-09T02:37:25+00:00

Problem: Looking to select 1 row of each type Table: EntryPrices AttendingTypesId (int) Name

  • 0

Problem: Looking to select 1 row of each type

Table: EntryPrices

AttendingTypesId (int)

Name (nvarchar)

Price (int)

GroupId (int)

FromDate (DateTime) //yyyy-MM-dd

Sample:
Basic entry – 100 – 1 – 2012-08-01

Sponsor entry – 350 – 2 – 2012-08-01

Staff entry – 70 – 3 – 2012-08-01

Basic entry – 150 – 1 – 2012-10-01

Basic entry – 200 – 1 – 2012-12-01

As you can see, there are 3 basic entries. Each is valid depending on the date when they registered.
So if a person registers in mid september, he gets it for 100
mid November 150 and end December 200.

However i want to get the “valid” fee depending on todays date and i want to list that in a dropdown list.

So if i query this today (2012-aug-02) i should get the following
rows:

Basic entry – 100 – 1 – 2012-08-01

Sponsor entry – 350 – 2 – 2012-08-01

Staff entry – 70 – 3 – 2012-08-01

If i query this (2012-dec-20) i should get the following rows:

Sponsor entry – 350 – 2 – 2012-08-01

Staff entry – 70 – 3 – 2012-08-01

Basic entry – 200 – 1 – 2012-12-01

How can i construct this in linq-to-sql?

My idea was something like:

var f = from data in mc.AttendingTypes
                    where DateTime.Now.CompareTo(data.FromDate) > 0
                    group data by new { data.GroupId, data.Name, data.Price, data.AttendingTypesId }
                    into newData
                    select new { newData.Key.Name, newData.Key.Price, newData.Key.AttendingTypesId };
  • 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-06-09T02:37:27+00:00Added an answer on June 9, 2026 at 2:37 am

    I’d rather do something like that :

    var today = DateTime.Now;
    
    var result = mc.AttendingTypes
                 .Where(at => at.FromDate <= today)
                 .GroupBy(at => at.GroupId)
                 .Select(g => g.OrderByDescending(m => m.FromDate).FirstOrDefault())
                 .ToList();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi there I have big problem with one select query There is a table:
I have an SSIS package which iterates over a table, and for each row
Is there a better solution to the problem of looking up multiple known IDs
Ok, this is an embarassingly simple-looking problem, but is driving me crazy. I'm learning
Hej everyone, problem : I am looking for right way to convert an index
Problem Hey folks. I'm looking for some advice on python performance. Some background on
Thanks for looking on this problem. I have a page that is totally valid
My problem is that I was looking for way to use both storyboard and
I am looking for a simple answer for this problem... I have a UITextView
I'm looking for the generally accepted/best solution to this problem. Problem I have a

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.