Skip to content

Instantly share code, notes, and snippets.

@hazzik
Last active August 29, 2015 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hazzik/ae6f9185ceb186004f50 to your computer and use it in GitHub Desktop.
Save hazzik/ae6f9185ceb186004f50 to your computer and use it in GitHub Desktop.
NHibernateQuery
interface IQuery<TCriteria, TResult> { TResult Execute(TCriteria criteria); }
class BooksWithISBN { public string ISBN { get; set; } }
class BooksWithISBNQuery : IQuery<BooksWithISBN, IEnumerable<Book>> {
public IEnumerable<Book> Execute(BooksWithISBN criteria) {
return session.Query<Book>().Where(b => b.ISBN == criteria.ISBN).AsEnumerable();
}
}
interface IQuery<TResult>
interface IBooksWithISBN : IQuery<TResult> { string ISBN { get; set; } }
class BooksWithISBNQuery : IBooksWithISBN {
public string ISBN { get; set; }
public IEnumerable<Book> Execute() {
return session.Query<Book>().Where(b => b.ISBN == ISBN).AsEnumerable();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment