Parameter
Holds the information required to construct a data parameter. Used internally by QueryGroup and QueryField to manage parameter creation.
The library uses this class as the basis for creating DbParameter objects.
Usability
var parameter = new Parameter("@Id", 10045);
Or with a DbType.
var parameter = new Parameter("@Id", 10045, DbType.String);
QueryField
QueryField instantiates this class internally.
var queryField = new QueryField("Id", 10045);
var parameter = queryField.Parameter;
var name = parameter.Name; // @Id
var value = parameter.Value; // 10045
QueryGroup
Since QueryGroup groups a list of QueryField objects, parameters can also be extracted from it.
var queryFields = new[]
{
new QueryField("LastName", Operation.Like, "Doe%"),
new QueryField("State", "Michigan")
};
var queryGroup = new QueryGroup(queryFields);
// Extract
var parameters = queryGroup
.GetFields(true)
.Select(qf = qf.Parameter);
// Make the stuffs for the 'parameters' here
Reset
Resets the instance to its initial state after instantiation.
var parameter = new Parameter("@Id", 10045, false);
// Do the stuffs for the 'parameter' here
parameter.Reset();
If QueryField.IsForUpdate() was called, the parameter name is prefixed with an underscore (
_). CallingReset()restores the original name.