You can download from Microsoft DynamicQuery class this will help you a lot and it make your job easy.
http://msdn.microsoft.com/en-US/vstudio/bb964686.aspx
For example
public IEnumerable<T> GetAll<T>()
{
return this.AddIncludes(this.DbContext.Set<T>()).OrderBy (this.SortSpec.PropertyName).ToList();
}
public IEnumerable<T> Find(Expression<Func<T, bool>> expression)
{
return this.AddIncludes(this.DbContext.Set<T>()).Where(expression).OrderBy(sortingPropertyName).ToList();
}
Read this blog:
http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx
Combine your Repository pattern with UnitOfWork pattern this will give you a better abstraction.
The repsoistory interface shall contains only the importent methods like:
public interface IRepository<T>
{
List<string> IncludeList { get; } // Include for EF
IEnumerable<T> GetAll<T>();
void Delete(T);
void Add(T);
IEnumerable<TEntity> Find(Expression<Func<T, bool>> expression);
}
IRepository might be also offer other methods like Any, GetRange etc, if you want.
NOW TO YOUR Q!
I read that the IQueryable implements the IEnumerable, so. Can i create my select functions using only IQueryable return type or not???
"The difference is that IQueryable is the interface that allows LINQ-to-SQL (LINQ.-to-anything really) to work. So if you further refine your query on an IQueryable, that query will be executed in the database, if possible.
For the IEnumerable case, it will be LINQ-to-object, meaning that all objects matching the original query will have to be loaded into memory from the database."
See: Returning IEnumerable<T> vs. IQueryable<T>