The
All
method returns all data from a table.
public SimpleQuery All( SimpleExpression criteria )
criteria
SimpleExpression
db.Albums.AlbumId.Count() > 2.
Type:
SimpleQuery
A collection of
SimpleRecord
objects which can be iterated over.
Exception | Condition |
---|---|
BadExpressionException
|
criteria is a malformed SimpleExpression |
The
All
method generally ignores any
SimpleExpression
s passed to it, be they valid or invalid. The one exception to this rule is when writing a malformed expression using assignment rather than equality checking. For example
var albums = db.Albums.All(db.Albums.GenreId = null)
In this one case, Simple.Data throws a
BadExpressionException
The following example returns all the rows of the Albums table and outputs all the album titles to the Console window.
var albums = Database.Open().Albums.All(); foreach (var album in albums) { Console.WriteLine(album.Title); }
Simple.Data sends the following SQL to the database when albums is evaluated.
SELECT [dbo].[Album].[AlbumId], [dbo].[Album].[GenreId], [dbo].[Album].[ArtistId], [dbo].[Album].[Title], [dbo].[Album].[Price], [dbo].[Album].[AlbumArtUrl] from [dbo].[Album]
(which equates to
select * from [dbo].[Album]
)