performance - dotnet core azure documentdb linq lambda query not running query on server -


i'm running dotnet core , accessing documentdb.

when try run query using linq clause returns takes long time , doesn't seem filter on server. able resolve using sqlqueryspec run query , appears run query criteria on server.

is known issue or missing something?

the 1 doesn't work:

var query = _client.createdocumentquery<t>(documentcollection.documentslink).where(criteria);     return query.tolist(); 

criteria of type

func<t, bool> criteria 

the 1 work:

var documentquery = _client.createdocumentquery<t>(urifactory.createdocumentcollectionuri(_databasename, collectionname), query).asdocumentquery(); list<t> results = new list<t>(); while (documentquery.hasmoreresults) { results.addrange(await documentquery.executenextasync<t>()); } return results; 

query of type

sqlqueryspec query 

is feature lagging behind in dotnet core's implementation of documentdb sdk vs standard .net package?

the issue using func<t, bool> criteria. 1 you're using ienumerable. design ienumerable in-memory filtering (client-side).

createdocumentquery.where() returns iqueryable. need change criteria type expression<func<t, bool>>as expected createdocumentquery.

when use expression, linq expression converted database specific sql query , executed on server.

uri documentcollectionuri = urifactory.createdocumentcollectionuri(databaseid, collectionid); var query = client.createdocumentquery<t>(documentcollectionuri)                   .where(predicate)                   .asdocumentquery(); list<t> results = new list<t>(); while (documentquery.hasmoreresults) {     results.addrange(await documentquery.executenextasync<t>()); }  return results; 

where predicate expression<func<t, bool>>

one important thing remember: can use linq extentions have equivalent function in documentdb's sql language. example, can use take() cannot use skip(), cannot use array contains on specific nested fields, etc.


Comments