I am trying to group by my results and the check null but it throwing error on .Any()
or .Count()
and someDocs
is in memory collection
var devices = someDocs.SelectMany(x => x.Devices).GroupBy(x => x.type);
if (devices != null && devices.Count()>0) // Exception : Object not set to instance of Object
{
//my code
}
How can I check that grouped result is null?