1
votes

Though DocumentDb supports string range comparisons,

client.CreateDocumentQuery<Family>( collectionLink, "SELECT * FROM Families f WHERE f.Address.State > 'NY'", new FeedOptions { EnableScanInQuery = true });

You can also construct DocumentDB Linq queries like this.

var zipLinqQuery = from z in db.ZIPMASTERs where z.CORP == listItem.CORP && z.ZIPBEG.CompareTo(listItem.ZIPCODE) <= 0 && z.ZIPEND.CompareTo(listItem.ZIPCODE) >= 0 select z;

from Issues Doing a String Comparison in LINQ

I am unable to dynamically construct Linq string comparison queries using Linq Expressions:

Expression<Func<string, string, bool>> stringCompare = (x, y) => x.CompareTo(y) > 0; return Expression.Invoke(stringCompare, new[] { left, right });

Produces the following output.

(Invoke((x, y) => x.CompareTo(y), x.state, "NY") > 0)

It seems, the DocumentDB API does not support Invoke and it does not support "Compare". It supports "CompareTo" as described above but not when dynamically constructing a Linq Expression Tree. Any suggestions greatly appreciated.

1

1 Answers

0
votes

Try it this way (where Item is the C# representation of your object):

Expression<Func<Item, bool>> filterDateExpression = d => d.DateUploadedUTC.CompareTo(fromS) >= 0 &&
                                                         d.DateUploadedUTC.CompareTo(toS) <= 0;

Hope this helps!