OpenPetra
Free Administration Software for Non-Profits
Ict.Common.DB.TDbListParameterValue Class Reference

A list of parameters which should be expanded into an ‘IN (?)’ context. More...

Inheritance diagram for Ict.Common.DB.TDbListParameterValue:

Public Member Functions

 TDbListParameterValue (String name, OdbcType type, IEnumerable value)
 Create a list parameter, such as is used for 'column IN (?)' in SQL queries, from any IEnumerable object. More...
 
IEnumerator GetEnumerator ()
 Get the generic IEnumerator over the sub-OdbcParameters. More...
 
override String ToString ()
 Represent this list of parameters as a string, using each value's ToString() method. More...
 

Static Public Member Functions

static OdbcParameter OdbcListParameterValue (String name, OdbcType type, IEnumerable value)
 Convenience method for creating an OdbcParameter with an appropriate TDbListParameterValue as a value. More...
 

Public Attributes

OdbcParameter OdbcParam
 The OdbcParameter from which sub-parameters are Clone()d. More...
 

Detailed Description

A list of parameters which should be expanded into an ‘IN (?)’ context.

Simply use the following style in your .sql file:

SELECT * FROM table WHERE column IN (?)

Then, to test if column is the string "First", "Second", or "Third", set the OdbcParameter.Value property to a TDbListParameterValue instance. You can use the TDbListParameterValue.OdbcListParameterValue() function to produce an OdbcParameter with an appropriate Value property.

OdbcParameter[] parameters = new OdbcParamter[]
{
TDbListParameterValue(param_grdCommitmentStatusChoices", OdbcType.NChar,
new String[] { "First", "Second", "Third" }),
};
TDbListParameterValue(String name, OdbcType type, IEnumerable value)
Create a list parameter, such as is used for 'column IN (?)' in SQL queries, from any IEnumerable obj...
Definition: Utilities.cs:108

Constructor & Destructor Documentation

◆ TDbListParameterValue()

Ict.Common.DB.TDbListParameterValue.TDbListParameterValue ( String  name,
OdbcType  type,
IEnumerable  value 
)
inline

Create a list parameter, such as is used for 'column IN (?)' in SQL queries, from any IEnumerable object.

Parameters
nameThe ParameterName to use when creating OdbcParameters.
typeThe OdbcType of the produced OdbcParameters.
valueAn enumerable collection of objects. If there are no objects in the enumeration, then the resulting query will look like column IN (NULL) because column IN () is invalid. To avoid the case where the query should not match any rows and column may be NULL, use an expression like (? AND column IN (?). Set the first parameter to FALSE if the list is empty and TRUE otherwise so that the prepared statement remains both syntactically and semantically valid.

Member Function Documentation

◆ GetEnumerator()

IEnumerator Ict.Common.DB.TDbListParameterValue.GetEnumerator ( )
inline

Get the generic IEnumerator over the sub-OdbcParameters.

◆ OdbcListParameterValue()

static OdbcParameter Ict.Common.DB.TDbListParameterValue.OdbcListParameterValue ( String  name,
OdbcType  type,
IEnumerable  value 
)
inlinestatic

Convenience method for creating an OdbcParameter with an appropriate TDbListParameterValue as a value.

◆ ToString()

override String Ict.Common.DB.TDbListParameterValue.ToString ( )
inline

Represent this list of parameters as a string, using each value's ToString() method.

Member Data Documentation

◆ OdbcParam

OdbcParameter Ict.Common.DB.TDbListParameterValue.OdbcParam

The OdbcParameter from which sub-parameters are Clone()d.


The documentation for this class was generated from the following file: