oysteinkrog / SQLite.Net-PCL

Simple, powerful, cross-platform SQLite client and ORM - Updated version with PCL support
MIT License
353 stars 162 forks source link

AsyncTableQuery.OrderBy with TValue? #302

Open reader-man opened 8 years ago

reader-man commented 8 years ago

Hi, You have made the where clause like this:

public AsyncTableQuery<T> Where([NotNull] Expression<Func<T, bool>> predExpr); but the order by, like this:

public AsyncTableQuery<T> OrderBy<TValue>([NotNull] Expression<Func<T, TValue>> orderExpr);

with the where clause we can make variables and lists of the expression to be sent to a mediator aka Repository, like so:

private Expression<Func<TEntity, bool>> _filter { get; set; }

but we cant make the same thing to the order by, unless we make the [TValue] to [object], like so:

        public Expression<Func<TEntity, object>> SortExpresion { get; set; }
        public System.Collections.Generic.Dictionary<int, Expression<Func<TEntity, object>>> SortExpresionList { get; set; }

so 1 is it possible to have another added function, lets say:

public AsyncTableQuery<T> OrderBy<String>([NotNull] Expression<Func<T, String>> orderExpr);

2 and is my use of the object instead of the TValue, a correct one?

3 the children made me forget :)

p.s. the "Expression<Func<TEntity, object>>", is a struct of orderBy enum, and Expression<Func<TEntity, object>>, but wrote here like that for brevity.