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. For example, Simple.Data includes a method to return the length of a field as a string.


Return the number of characters in a text field or in the text representation of a field.


public FunctionReference Length( )


Length takes no parameters

Return Value

Type: FunctionReference
A reference to a column being selected with a string length function applied to it


Exception Condition
InvalidOperationException Length has been used or daisychained to a base function (All, FindAllBy, …) rather than to a column in a Select clause.
NullReferenceException Length has been daisychained to a table reference rather than a column reference within a Select clause.
ArgumentException You have passed one or more arguments to Length

Note that issues #289 - #290 are still open with regards to exceptions thrown by Length.


Length must be called only within a Select clause, appended to one of the fields being selected.



To return the length of each title of the Albums in the Albums table, and reference it as TitleLength, use the following code:

var details = db.Albums.Select(db.Albums.Title.Length().As("TitleLength"));

Simple.Data sends the following SQL to the database when details is evaluated

   len([dbo].[Albums].[Title]) AS [NameLength]
from [dbo].[Albums]