Simple.Data

Simple.Data defines a number of commands for retrieving data from a data store. These can then be daisychained in a LINQ-like fashion with further methods to modify the basic query.

All

The Allmethod returns all data from a table.

Syntax

public SimpleQuery All( SimpleExpression criteria )
    

Parameters

criteria
Type: SimpleExpression
A (concatenated sequence of) search criteria for a group or an aggregate function. For example, db.Albums.AlbumId.Count() > 2.

Return Value

Type: SimpleQuery
A collection of SimpleRecordobjects which can be iterated over.

Exceptions

Exception Condition
BadExpressionException criteriais a malformed SimpleExpression

Remarks

The Allmethod generally ignores any SimpleExpressions 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

Examples

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])