score:7
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.
score:1
with .toarray(), you are using linq against a .net type, which is evaluated in code and uses .net type handling. here, the string concatenation methods work the way you are used to.
without .toarray, your query is executed in the dbms and uses whatever that system is configured to use for null values.
in this case the dbms is configured to handle nulls according to the ansi standard, which is very different from .net in places. you should look up ansi nulls to find out the details. it isn't complicated, but can be confusing if you aren't expecting it.
two addenda 1) first, i believe the concatenation rules for nulls are laid out in the ansi standard, but actually i realize i could be wrong. i came from a sql server background, where ansi_nulls is a setting controlling null equality, whereas concatenation is controlled by another one. if i am wrongly linking the latter to the former, i apologize.
2) despite my talking about configurability, and the fact that sql server at least does allow changing that configuration, it is absolutely the case that the behavior you are seeing is standard, default, and expected. you should get used to it if you will be working with databases much at all.
Source: stackoverflow.com
Related Query
- Why does a null string concatenated to a non null string evaluate to null?
- Why does not null in LINQ query still return null records?
- Why does EF not return any results when comparing null variable?
- Why does this LINQ query assign a value of 1 to a NULL value from the database?
- Why does "SingleOrDefault" return null on second execution when there is data in DB?
- why does this linq code get exponentially slower when applying First() to projection?
- Why does lambda expression assume char instead of string
- Why does Linq on date range return null on a combined query, works fine on a seperated query
- C# XML - Why does this Code keep failing with 0x3A Error?
- List or Array of String Contain specific word in Html Source Code
- Why does Resharper suggest a code change and then complain about the change?
- Why does my code not find directories
- Why does this Linq method throw a Null Reference Exception
- Why does Entity Framework FindFirstOrDefault returns ExecutionException instead of null
- Why does this LINQ statement return null and not a IEnumerable with count=0
- Why this multi linq join code does not work?
- Why does my string not parse properly in my linq to objects query?
- Why does ReSharper tell me "implicitly captured closure"?
- Why does Enumerable.All return true for an empty sequence?
- C# - code to order by a property using the property name as a string
- Why does the C# compiler go mad on this nested LINQ query?
- Why does IEnumerable<T>.ToList<T>() return List<T> instead of IList<T>?
- Why does this method result in an infinite loop?
- Why does Enumerable.Single() iterate all elements, even when more than one item has already been found?
- The data source does not support server-side data paging
- Why does IQueryable.All() return true on an empty collection?
- LINQ syntax where string value is not null or empty
- What does this C# code with an "arrow" mean and how is it called?
- Why does this Linq Cast Fail when using ToList?
- Why does C# compiler create private DisplayClass when using LINQ method Any() and how can I avoid it?
More Query from same tag
- looking for a better way to get a count-per-city
- Generic Linq ordering function?
- How do you JOIN/GROUP/Max/Min all within Linq?
- linq query returns too many results
- Get entire XML except root element
- Return comma delimited string with just the values
- How to do Multiple Left Join, Group By, and Concatenate in LINQ
- Creating generic method
- Compare Arrays in C# using SequenceEqual
- LINQ Select on string results in char
- Optimizing A LINQ To Objects Query
- 2D Array get number of not null rows
- Best way to convert Dictionary<string, string> into single aggregate String representation?
- Dealing with VB.NET Linq formatting in Visual Studio?
- How to implement Linq extensions in custom method?
- Insert many value using foreign key
- Reference anonymous type properties
- How properly work with LINQ to XML?
- Get n entities that either have no or least recent related entities
- Merge XDocuments by XAttribute's value
- Distinct Date with Linq
- How to use LINQ with dynamic collections
- Filter Custom Dictionary with LINQ ToDictionary - "Unable to cast object of type 'System.Collections.Generic.Dictionary`2"
- Linq statement only executing once and returning zero on second try and above in foreach loop
- Why is this LINQ not finding an element two levels down?
- How do I Pick the best performer from a set using LINQ
- How to add Month in date time and Compare with another date time in Linq?
- Where clause in LINQ query using a function
- To concatenate values of a particular column in multiple rows using linq
- Entity Framework: Any or All - Unable to create a constant value of type 'System.Collections.Generic.List`1'