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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:14:41+00:00 2026-06-07T00:14:41+00:00

I am having this Linq To SQL query which is taking Customer Category from

  • 0

I am having this Linq To SQL query which is taking Customer Category from database.The CustCategory will be defined already.Here is the query.

public IList<string> GetAccountType()
        {
            using (var db = new DataClasses1DataContext())
            {
                var  acctype = db.mem_types.Select(account=>account.CustCategory).Distinct().ToList();
                if (acctype != null)
                {
                    return acctype;
                }
            }

        }

Currently I am getting an error that Not all code paths return a value.If I am always certain that the value is there in the database then do I need to check for null,If I need to check for null then how do I handle this.
Can anyone help me with this.
Any suggestions are welcome.

  • 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-07T00:14:43+00:00Added an answer on June 7, 2026 at 12:14 am

    Since Enumerable.ToList never returns null (see the Return Value section of the documentation), you can safely remove the if.

    EDIT: Note that, no matter what your database contains, acctype will never be null:

    • If no value is found in the database, the return value will be an empty list (which is different than null).
    • If one record is found and its value is null, the return value will be a valid list with one entry, whose value is null. Still, the list itself is not null.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to convert this sql into my LINQ query and am having
I am having performance issues with this LINQ Query. The data is laoded into
I'm having a misunderstanding problem with this use of Linq Query I do have
I am having a real pain in converting this query expression into my LINQ
I'm having an issue getting a LINQ query to work. I have this XML:
My application constructs a Linq To Sql query and then populates a model which
I'm having difficuly mapping a simple T-SQL query such as this select min(price) as
I have a LINQ to SQL query and I'm having trouble to access the
I'm having some problems with the Sql query generated by LINQ, Since my environment
I'm having trouble rewriteing a complex sql query as linq. -- gets the SpecificationAttributeOptionIDs

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.