public virtual IQueryable <TEntity> GetAll <TSort>(Expression <Func <TEntity, bool> > whereExpression, Expression <Func <TEntity, TSort> > sortExpression, ListSortDirection sortDirection)
        {
            PropertyInfo sortProperty           = PropertyHelper.GetPropertyInfoCompilerProtected <TEntity, TSort>(sortExpression, BindingFlags.Public | BindingFlags.Instance | BindingFlags.FlattenHierarchy);
            bool         isDBPropertyExpression = EntityToSqlScript.IsPropertyDBProperty(sortProperty);

            if (sortDirection == ListSortDirection.Ascending)
            {
                if (isDBPropertyExpression)
                {
                    return(_session.All <TEntity, TEntityKey>().OrderBy(sortExpression).Where(whereExpression));
                }
                else
                {
                    List <TEntity> list = _session.All <TEntity, TEntityKey>().Where(whereExpression).ToList();
                    return(list.OrderBy(sortExpression.Compile()).AsQueryable());
                }
            }
            else
            {
                if (isDBPropertyExpression)
                {
                    return(_session.All <TEntity, TEntityKey>().OrderByDescending(sortExpression).Where(whereExpression));
                }
                else
                {
                    List <TEntity> list = _session.All <TEntity, TEntityKey>().Where(whereExpression).ToList();
                    return(list.OrderByDescending(sortExpression.Compile()).AsQueryable());
                }
            }
        }
        public virtual IQueryable <TEntity> GetAll(Expression <Func <TEntity, bool> > whereExpression, string sortPropertyName, ListSortDirection sortDirection)
        {
            if (string.IsNullOrEmpty(sortPropertyName))
            {
                sortPropertyName = "Id";
            }

            PropertyInfo sortProperty           = GetSortPropertyInfo(sortPropertyName);
            bool         isDBPropertyExpression = EntityToSqlScript.IsPropertyDBProperty(sortProperty);

            MethodInfo internalGetAllMethod            = this.GetType().GetMethod("InternalGetAll", BindingFlags.FlattenHierarchy | BindingFlags.Instance | BindingFlags.NonPublic);
            MethodInfo constructedInternalGetAllMethod = internalGetAllMethod.MakeGenericMethod(new Type[] { sortProperty.PropertyType });

            return((IQueryable <TEntity>)constructedInternalGetAllMethod.Invoke(this, new object[] { whereExpression, isDBPropertyExpression, sortPropertyName, sortDirection }));
        }