Encapsulates advanced options for making select requests.

Namespace: Simol
Assembly: Simol (in Simol.dll) Version: 1.0.0.0

Syntax

C#
public class SelectCommand : ICloneable
Visual Basic
Public Class SelectCommand _
	Implements ICloneable
Visual C++
public ref class SelectCommand : ICloneable

Remarks

This class supports standard ADO.NET named parameter syntax. Simply prefix command parameters in your select statement with '@', and register a CommandParameter for each unique parameter in the statement. Here is an example that uses the generic version of SelectCommand<(Of <(<'T>)>)>:
CopyC#
string commandText = "select * from Person where Name = @Name";
SelectCommand<Person> command = new SelectCommand<Person>(commandText);
command.AddParameter("@Name", "Kate");
SelectResults<Person> results = simol.Select(command);

Parameters are formatted using the mapping rules defined for the related item type. Each command parameter must therefore be associated with a mapped property. This association is made automatically when the CommandParameterName matches a mapped property. When the parameter name does not match a mapped property you must set the CommandParameterPropertyName to explicitly create the parameter-property association. In the example above, the Name parameter would automatically assume the formatting rules of Person.Name.

For example, the query select * from Person where Birthday between @MinBirthday and @MaxBirthday requires that we explicitly map the MinBirthday and MaxBirthday parameters to Person.Birthday. To provide this mapping you must set CommandParameter.PropertyName" to "Birthday" for both parameters.

Other noteworthy considerations:

  • Parameter values are automatically wrapped by single-quotes and escaped when the command text is expanded (i.e. embedded single quotes are replaced by two single quotes--[O'Doul's] becomes ['O''Doul''s'])
  • Parameter names may contain only the following characters: a-z, A-Z, 0-9, '_', '-', and '.'

Inheritance Hierarchy

See Also