I'm trying to create a generic C# method that can return just the Id & Description (string) properties for a particular document type in a generic BasicObject class. (Most of my document types have Id & Description properties).
The method would accept the document type and (presumably) an expression that would be passed as a parameter to the .Select part of the query definition. The expression would convert the document type to a BasicObject (Id & Description properties).
I've tried the method below but RavenDB doesn't understand the expression. Is it possible to do what I need or do I have to implement the method for each document type.
public Task<List<T>> GetAllDocs(Expression<Func<T, BasicObject> convertExpression)
{
var query = _session.Query<T>
.Select(doc => convertExpression(doc));
var results = await query.ToListAsync();
return results;
}