Q:

How to check if returned array has atleast two elements?

Here is my code:-
Repository.DB.Table01Repository.AsQueryable().Where(item => (item.Name.Split(' ')[1] == null)).ForEach(items => _VerifyList.Add(items.Name.Trim()));
I split 'Name' by ' ' and if it does not have second element, I need those records.  
Thanks..

A:

Since Split will produce two or more elements if the Name contains at least one space, you can write it as follows:
Repository.DB.Table01Repository.AsQueryable()
    .Where(item => !item.Name.Contains(" "))
    .ForEach(items => _VerifyList.Add(items.Name.Trim()));

There's no need to actually perform the Split.
In addition, Contains can be mapped to SQL (it is one of the CLR methods that map to canonical LINQ functions) which means that the query will execute successfully on your database. Other methods (like Split itself) cannot be used when querying a database through IQueryable, and would cause a runtime exception to be thrown.

