Maybe it's simple question, but does AsQueryable() have some performance loss?
Generally speaking we are working with RavenDB and we have existing code like this
protected override IQueryable<T> QueryableIndexRawQuery(string rawQuery, int skip = 0, int take = 128, string indexName = null)
{
var defaultIndexName = !string.IsNullOrWhiteSpace(indexName) ? indexName : string.Format("{0}{1}", typeof(T).Name, IndexPreffix);
return this.Session.Advanced.DocumentStore.DatabaseCommands.GetIndex(defaultIndexName) != null
? this.Session.Advanced.LuceneQuery<T>(defaultIndexName).Statistics(out this.Statistics).Skip(skip).Take(take).Where(rawQuery).AsQueryable()
: this.Session.Advanced.LuceneQuery<T>().Statistics(out this.Statistics).Skip(skip).Take(take).Where(rawQuery).AsQueryable();
}
So Where clause return us IDocumentQuery then we try to represent it AsQueryable()
this.Session.Advanced.LuceneQuery<T>(defaultIndexName).Statistics(out this.Statistics).Skip(skip).Take(take).Where(rawQuery)
The question what AsQueryable() eventually does internally? How does it convert it?
Answers with in-memory collection examples like List<> will be really useful as well.
Like this:
var list = new List<string>() { "1", "2", "3" };
list.AsQueryable();
.AsQueryable() forces us to evaluate the query in memory, since you are using session.Advanced.LuceneQuery(). This is NOT recommended.
You need to use session.Query() if you want to use IQueryable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With