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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T02:45:26+00:00 2026-05-19T02:45:26+00:00

I currently have a LINQ statement that returns an IQueryable to be displayed into

  • 0

I currently have a LINQ statement that returns an IQueryable to be displayed into a Telerik RadGrid. This statement is set to pull Records that match the Period inputted, and also have the “Premium” Column set to true. It then selects the EmployeeID & ProjectID distinctly using the GroupBy property.

These columns are then displayed in the RadGrid, along with a “PremiumCode” column.
Currently my statement works to display ALL of the records that meet the top credentials (Employee Name, Project, Premium Code), but my end Goal is to pull only those Records which DONT already have a “PremiumCode” assigned to the Project for that particular Employee.

public static IQueryable GetEmptyPremiums(string Period)
    {
        DataContext Data = new DataContext();
        var PR = (from c in Data.System_Times
                  where c.Period == Period && c.Premium == true
                  orderby c.System_Employee.LName
                  select c).GroupBy(s => s.EmployeeID & s.ProjectID).Select(x => x.FirstOrDefault());

        return PR;
    }

Currently it is displaying properly, but every record is being displayed, not just the ones that require a PremiumCode.

alt text

Is there a way to re-work my LINQ statement to only include the records that need a PremiumCode?

EDIT:
Jay,
I have tried to modify your solution to fit my needs, but unfortunately with no success. Records in the Premium table are not added until a Premium Code is defined, therefore there will never be a null “PremiumCode”.

To describe my end-goal a tad more clearly: I am looking to show the information in a grid like in the image above. The records shown will be the distinct Time records that have the bool value “Premium” checked as true but don’t have a PremiumCode record in the Premium Table.

If the checked record has a matching record in the Premium table (EmployeeID, and ProjectID matching) then it already possesses a Premium Code set and will not need to be displayed in the Grid.

If the checked record has no matching record in the Premium table (EmployeeID, and ProjectID not matching) then it requires a PremiumCode and will need to be displayed in the Grid.

I believe this can be achieved with “.Any()” but I am having troubles aligning my Syntax and Logic to make this Grid display properly.

  • 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-19T02:45:27+00:00Added an answer on May 19, 2026 at 2:45 am

    How about:

     DataContext Data = new DataContext();
     var projectsWithoutPremium = Data.Premiums.Where(p => p.PremiumCode == null)
                                 .Select(p => p.ProjectId);
     var PR = (from c in Data.System_Times
              where c.Period == Period && c.Premium == true
                    && projectsWithoutPremium.Contains(c.ProjectId)
              orderby c.System_Employee.LName
              select c).GroupBy(s => s.EmployeeID & s.ProjectID).Select(x => x.FirstOrDefault());
    
     return PR;
    

    update in response to question edit

    DataContext Data = new DataContext();
    var PR = (from c in Data.System_Times
                 where c.Period == Period && c.Premium == true
                     && !Data.Premiums.Any(p => p.ProjectID == c.ProjectID && p.EmployeeID == c.ProjectID) 
                 orderby c.System_Employee.LName select c)
                 .GroupBy(s => s.EmployeeID & s.ProjectID)
                 .Select(x => x.FirstOrDefault());
    
    return PR;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have this linq statement: from s in SubContentRevisions where s.SubContentID.Equals(e3f319f1-65cc-4799-b84d-309941dbc1da) && s.RevisionNumber
I have a LINQ query that returns all absences for an employee. The first
I have a SQL Statement that I am trying to convert to a LINQ
I currently have a fairly long LINQ statement which pulls data from two tables:
I have a method that sets up my linq data context. Before it returns
I have a good LINQ query that is working well, it returns a result
Currently I have a DataModel object which contains my linq to sql classes(a dmbl
I am currently learning C# and LINQ. I have lots of questions about them.
I have a short question. Im my current project I'm using LINQ-to-SQl. That is
I currently have an MS Access application that connects to a PostgreSQL database via

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.