Skip to content
schotime edited this page Apr 27, 2012 · 1 revision

Here are some of the ways to fetch multiple rows from the database.

Eager

1: Fetch all

List<User> users = db.Fetch<User>();

2: Fetch with criteria

List<User> users = db.Fetch<User>("where isActive = 1");

3: Fetch with raw SQL

List<User> users = db.Fetch<User>("select u.* from users where u.isActive = 1");

Lazy

Warning: The following method Query uses the yield keyword. It will only run the query when the results are being iterated over. Please use the Fetch method if you don't fully understand this concept.

List<User> users = db.Query<User>("select u.* from users where u.isActive = 1");

Clone this wiki locally