Created
August 17, 2010 21:20
-
-
Save donnfelker/532103 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List<int> userIds = (from item in _userRepository.Fetch() | |
where item.Name.Contains(search) | |
|| item.Role.Name.Contains(search) | |
select item.User.Id); | |
// Or | |
var stuff = _repository.Fetch(); | |
var result = stuff.Where(x => x.StuffId== someId && (x.StuffName == null || x.StuffType != null)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface IQueryableRepository<T>: IRepository<T> | |
{ | |
IQueryable<T> Fetch(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class QueryableRepository<T> : Repository<T>, IQueryableRepository<T> | |
{ | |
// Repository<T> comes from Sharp Arch. | |
public IQueryable<T> Fetch() | |
{ | |
ISession session = Session; | |
var query = from item in session.Linq<T>() select item; | |
return query; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment