public TEntity GetSingleOrderBy(Expression <Func <TEntity, TKey> > keySelector, Expression <Func <TEntity, bool> > predicate) { var queryCriteria = new ExpressionQuery <TEntity>(); queryCriteria.OrderBy(keySelector); if (predicate != null) { queryCriteria.And(predicate); } var find = queryCriteria.Execute(Set); return(find.FirstOrDefault()); }