Reputation: 150
I want to retrieve about 50 - 100 documents by their ID from DocumentDb. I have the list of IDs in a List<string>
. How do I use LINQ to SQL to retrieve those documents. I don't want to write the actual SQL query as a string, as in:
IQueryable<Family> results = client.CreateDocumentQuery<Family>(collectionUri, "SELECT * FROM family WHERE State IN ('TX', 'NY')", DefaultOptions);
I want to be able to use lambda expressions to create the query, because I don't want to hard-code the names of the fields as string.
Upvotes: 0
Views: 238
Reputation: 27793
It seems that you do not want to generate and pass query string SELECT * FROM family WHERE State IN ('TX', 'NY')
to query documents, you could try the following code.
List<string> ids = new List<string>() { "TX", "NY" };
client.CreateDocumentQuery<Family>(collectionUri).Where(d => ids.Contains(d.id));
Upvotes: 4