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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:20:58+00:00 2026-06-14T03:20:58+00:00

I have an old FoxPro program that does a SQL query which includes the

  • 0

I have an old FoxPro program that does a SQL query which includes the following:

            SELECT  Region,                        
                    Year AS yr_qtr,                  
                    SUM(Stock) AS inventory   

**…

                   COUNT(Rent) AS rent_ct     
            FROM                                         

**…

            GROUP   BY Region, Year           
            ORDER   BY Region, Year
            INTO    CURSOR tmpCrsr

The query is against a .DBF table file, and includes data from an Excel file. I’ve used both to populate an enumeration of user-defined objects in my C# program. (Not sure .AsEnumerable is needed or not.) I then attempt to use LINQ to Dataset to query the list of user objects and create the same result set:

var rslt1 = from rec in recs_list //.AsEnumerable()
            group rec by new {rec.Region, rec.Year} into grp
            select new
{
    RegName = grp.Key.Region,
    yr_qtr = grp.Key.Year,
    inventory = grp.Sum(s => s.Stock),
    // ...
    rent_count = grp.Count(r => r.Rent != null)
};

This gives me the warning that “The result of the expression is always ‘true’ since a value of type ‘decimal’ is never equal to ‘null’ of type ‘decimal’” for the Count() of the Rent column.

This makes sense, but then how do I do a count exclusive of the rows that have a value of .NULL. for that column in the FoxPro table (or NULL in any SQL database table, for that matter)? I can’t do a null test of a decimal value.

  • 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-14T03:20:59+00:00Added an answer on June 14, 2026 at 3:20 am

    If rent is based off of a column which is not a nullable value, then checking for null makes no sense which I believe the compiler accurately shows. Change the line to

    rent_count = grp.Count(r => r.Rent != 0)
    

    instead.

    For if the code is actuall nullable such as:

    Decimal? rent; 
    

    That would make checking rent against null valid. If that is the case then the line would be:

    rent_count = grp.Count(r => (r.Rent ?? 0) != 0)
    

    where null coalesding operator ?? can be used. Which states if r.rent is null, use the value 0 (or any value you want technically) for r.Rent. in the next process.

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

Sidebar

Related Questions

I have an old FoxPro program which can send reports to my network printer
I have old code that uses size_t which IIRC comes from cstring.h. On OS
I have old .prc files (SQL Server Stored Procedures) which have exported from SQL
I have a old school c program that now and then need to tell
I have an old program that saves its files to Program Files. We are
I have an old app that I'm supporting and I ran across the following
I have old text inside a div. I want that text to fly out
Most of the software company have old software which continue maintain, and they also
I have refereed old questions and found that people face many issues after installing
I have an old skin that I need to adapt to the new MediaWiki

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.