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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T09:02:47+00:00 2026-06-05T09:02:47+00:00

var users=db.Users.Where(u => u.Name.StartsWith(term) || u.Email.StartsWith(term) || u.FirstName.StartsWith(term)).ToArray(); var jsos=users.Select(u => new { label

  • 0
 var users=db.Users.Where(u => u.Name.StartsWith(term) || u.Email.StartsWith(term) || u.FirstName.StartsWith(term)).ToArray();
 var jsos=users.Select(u => new { label = u.FirstName  +" "+  u.Name+ " (" + u.Email+")", value = u.Id });

Works as expected. But, without the ToArray(), I get what appears to be strange behaviour: a null firstName results in the label being evaluated as null. With ToArray() I get the expected behaviour. (null is treated as an empty string and concatenated to the other non empty strings). Why?

  • 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-05T09:02:48+00:00Added an answer on June 5, 2026 at 9:02 am

    In the SQL world, by definition, any expression that has NULL as part of it becomes NULL. This is because NULL means an indeterminate value – an indeterminate value + anything else is still an indeterminate value, i.e. NULL.

    Again, in SQL you could use something like COALESCE to convert NULLs into, say, a blank string – I don’t recall off hand what the linq equivalent is.

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

Sidebar

Related Questions

Say I have this code: var users = [ { name: 'TJ', email: 'tj@earnboost.com'
I have some Mongoose Models with geospacial indexes: var User = new Schema({ name
i am trying to do using (UserManagementDataContext context = new UserManagementDataContext()) { var users
Say for example I have an object of var user = { Name: Dan,
Suppose I have a user Schema as below var User = new db.Schema({ username
I'm using the Facebook php-sdk to get the users name and friends, right now
I love new Rail 3! The new query syntax is so awesome: users =
I have two tables, users{name,id,age_range_id} and age_ranges{id,range_name} . There are also two models, controllers
Any idea why the following code will not compile? IEnumerable users; using (var ent
I have this code var users = result.users; // array $(#dialog:ui-dialog).dialog(destroy); $(#dialog-confirm).dialog({ resizable: false,

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.