6

Using v1.8 .Net SDK

Trying return Sales where the Sale client array contains the Client ID I’m looking for.

Sales.Where(sale => sale.Clients.Any(c => c.ClientId == clientID));

Returns Error "Nullable object must have a value."

at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task1.GetResultCore(Boolean waitCompletionNotification) at System.Threading.Tasks.Task1.get_Result() at Microsoft.Azure.Documents.Linq.DocumentQuery1.GetEnumerator() at System.Collections.Generic.List1..ctor(IEnumerable1 collection) at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source)

ClientID is a GUID, but trying to query any property on the client object returns the same error.

If I run the same query on the same data but just using a List collection (i.e. not using DocumentDB) then all is fine.

Any advice appreciated. Thanks

Chris Small
  • 363
  • 1
  • 3
  • 13

1 Answers1

12

This query can be alternatively expessed using SelectMany + Where:

Sales.SelectMany(s => s.Clients.Where(c => c.ClientID == clientID).Select(c => s));  
Aravind Krishna R.
  • 7,885
  • 27
  • 37