Class ArgumentParameterCollection
This class contains a structure like (FieldInfo, Parameter). The class is used for example when dealing with insert-statements, ex:
INSERT INTO associate T0(T0.associate_id, T0.name, T0.person_id) VALUES(1, 'SuperOffice', 2)
This example will look like this when coded:
AssociateTableInfo a = TablesInfo.GetAssociateTableInfo( "a" );
Insert i = S.NewInsert();
i.FieldValuePairs.Add( a.AssociateId, S.Parameter( 1 ) );
i.FieldValuePairs.Add( a.Name, S.Parameter( "SuperOffice" ) );
i.FieldValuePairs.Add( a.PersonId, S.Parameter( 2 ) );
Inherited Members
Namespace: SuperOffice.Data.SQL
Assembly: SoDataBase.dll
Syntax
public class ArgumentParameterCollection : IEnumerable, ICloneable
Constructors
ArgumentParameterCollection()
Initializes a new instance of the ArgumentParameterCollection class.
Declaration
public ArgumentParameterCollection()
Properties
Count
Get number of elements in collection
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
int |
FieldInfos
Returns the FieldInfo-collection
Declaration
public ICollection FieldInfos { get; }
Property Value
Type | Description |
---|---|
ICollection |
this[FieldInfo]
Returns the correct Parameter-object based on the in-parameter (FieldInfo).
Declaration
public Argument this[FieldInfo argument] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
FieldInfo | argument |
Property Value
Type | Description |
---|---|
Argument |
Parameters
returns the parameter collection
Declaration
public ICollection Parameters { get; }
Property Value
Type | Description |
---|---|
ICollection |
Tables
This class contains a structure like (FieldInfo, Parameter). The class is used for example when dealing with insert-statements, ex:
INSERT INTO associate T0(T0.associate_id, T0.name, T0.person_id) VALUES(1, 'SuperOffice', 2)
This example will look like this when coded:
AssociateTableInfo a = TablesInfo.GetAssociateTableInfo( "a" );
Insert i = S.NewInsert();
i.FieldValuePairs.Add( a.AssociateId, S.Parameter( 1 ) );
i.FieldValuePairs.Add( a.Name, S.Parameter( "SuperOffice" ) );
i.FieldValuePairs.Add( a.PersonId, S.Parameter( 2 ) );
Declaration
protected TableInfoCollection Tables { get; set; }
Property Value
Type | Description |
---|---|
TableInfoCollection |
Methods
Add(FieldInfo, Argument)
Adds paired data to the structure, for example
AssociateTableInfo a = TablesInfo.GetAssociateTableInfo( "a" );
Insert i = S.NewInsert();
i.FieldValuePairs.Add( a.PersonId, S.Parameter( 2 ) );
At the same time, we add the tableInfo's parent to a TableInfoCollection.
Declaration
public void Add(FieldInfo fieldArg, Argument arg)
Parameters
Type | Name | Description |
---|---|---|
FieldInfo | fieldArg | |
Argument | arg |
Clone()
Partial implementation of Clone, for copying the most-likely-to-be-variable parts of a query
Declaration
public object Clone()
Returns
Type | Description |
---|---|
object | Hybrid deep/shallow copy of object |
Remarks
This cloning function will return a collection that contains:
- References to keys (FieldInfo objects)
- Clones of Arguments of type Parameter
- References to Arguments of other types than Parameter
- References to the TableInfo objects
CloneAndExtendWithEquivalents(TableInfo, int, params FieldInfo[])
Clone the this, and check that all requiredFields have an equivalent (by SoField) field in the return value. If any fields are missing, fetch them from the database and add to the return value.
Declaration
public ArgumentParameterCollection CloneAndExtendWithEquivalents(TableInfo sourceTable, int sourceId, params FieldInfo[] requiredFields)
Parameters
Type | Name | Description |
---|---|---|
TableInfo | sourceTable | Identification of table to use when fetching data from the database |
int | sourceId | Primary key to use for fetcing data |
FieldInfo[] | requiredFields | Fields whose equivalents should be present in the result |
Returns
Type | Description |
---|---|
ArgumentParameterCollection | Clone, guaranteed to contain at least the requiredFields, plus whatever else was in the original collection |
Remarks
The purpose of this method is to ensure that an ArgumentParameterCollection contains at least the fields that are specified in the parameter requiredFields. The specification is taken in terms of field equivalents, i.e., looking at the SoField definitions and not the complete FieldInfo (which is connected to a particular TableInfo instance).
Fields that do not have their equivalent in the original collection will be fetched from the table identified by sourceTable, using the primary key sourceId. There will be at most one database access. All fields specified by requiredFields must belong to the same table (SoTable) as the sourceTable.Exceptions
Type | Condition |
---|---|
SoIllegalOperationException | Thrown if requiredFields.Parent.Definition is not the same table name as sourceTable.Definition |
GetEnumerator()
See MSDN-documentation for IEnumerator.
Declaration
public IEnumerator GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator |
GetEquivalentField(SoField)
Search the arguments to see if a field exists that is equivalent (i.e., same field in same table) as the incoming dictionary field
Declaration
public FieldInfo GetEquivalentField(SoField field)
Parameters
Type | Name | Description |
---|---|---|
SoField | field | Field definition to look for |
Returns
Type | Description |
---|---|
FieldInfo | The first corresponding fieldinfo, if one exists |
HasField(FieldInfo)
Check if the given field exists in the parameter collection
Declaration
public bool HasField(FieldInfo argument)
Parameters
Type | Name | Description |
---|---|---|
FieldInfo | argument | FieldInfo specifying the field to be found |
Returns
Type | Description |
---|---|
bool | true if the field exists, according to IsSameField(FieldInfo) |
HasFieldValue(FieldInfo)
Check if the given field exists in the parameter collection, and has a non-null value
Declaration
public bool HasFieldValue(FieldInfo argument)
Parameters
Type | Name | Description |
---|---|---|
FieldInfo | argument |
Returns
Type | Description |
---|---|
bool |
HasSameField(FieldInfo)
This class contains a structure like (FieldInfo, Parameter). The class is used for example when dealing with insert-statements, ex:
INSERT INTO associate T0(T0.associate_id, T0.name, T0.person_id) VALUES(1, 'SuperOffice', 2)
This example will look like this when coded:
AssociateTableInfo a = TablesInfo.GetAssociateTableInfo( "a" );
Insert i = S.NewInsert();
i.FieldValuePairs.Add( a.AssociateId, S.Parameter( 1 ) );
i.FieldValuePairs.Add( a.Name, S.Parameter( "SuperOffice" ) );
i.FieldValuePairs.Add( a.PersonId, S.Parameter( 2 ) );
Declaration
public bool HasSameField(FieldInfo argument)
Parameters
Type | Name | Description |
---|---|---|
FieldInfo | argument |
Returns
Type | Description |
---|---|
bool |
Remove(FieldInfo)
Remove a field from the collection
Declaration
public void Remove(FieldInfo field)
Parameters
Type | Name | Description |
---|---|---|
FieldInfo | field |
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string |
Overrides
TryGetDateTimeValue(SoField, out DateTime)
Try to retrieve the value of a parameter as a datetime
Declaration
public bool TryGetDateTimeValue(SoField argument, out DateTime value)
Parameters
Type | Name | Description |
---|---|---|
SoField | argument | Which parameter to look for; the first field that matches the definition will be used |
DateTime | value | Output value, 0 if the parameter does not exist |
Returns
Type | Description |
---|---|
bool | true if the parameter existed and had a non-null value of a compatible type |
Remarks
This method takes an SoField instead of a FieldInfo, so that you do not have to know the exact TableInfo instance of the field. On the other hand, if there is aliasing (multiple occurrences of fields from the same table, but different TableInfo instances), then you cannot distinguish between them and will get the first one.
TryGetDateTimeValue(FieldInfo, out DateTime)
Try to retrieve the value of a parameter as a datetime
Declaration
public bool TryGetDateTimeValue(FieldInfo argument, out DateTime value)
Parameters
Type | Name | Description |
---|---|---|
FieldInfo | argument | Which parameter to look for, exact match required |
DateTime | value | Output value, 0 if the parameter does not exist |
Returns
Type | Description |
---|---|
bool | true if the parameter existed and had a non-null value of a compatible type |
TryGetDoubleValue(SoField, out double)
Try to retrieve the value of a parameter as a Double
Declaration
public bool TryGetDoubleValue(SoField argument, out double value)
Parameters
Type | Name | Description |
---|---|---|
SoField | argument | Which parameter to look for; the first field that matches the definition will be used |
double | value | Output value, 0 if the parameter does not exist |
Returns
Type | Description |
---|---|
bool | true if the parameter existed and had a non-null value of a compatible type |
Remarks
This method takes an SoField instead of a FieldInfo, so that you do not have to know the exact TableInfo instance of the field. On the other hand, if there is aliasing (multiple occurrences of fields from the same table, but different TableInfo instances), then you cannot distinguish between them and will get the first one.
TryGetDoubleValue(FieldInfo, out double)
Try to retrieve the value of a parameter as a Double
Declaration
public bool TryGetDoubleValue(FieldInfo argument, out double value)
Parameters
Type | Name | Description |
---|---|---|
FieldInfo | argument | Which parameter to look for, exact match required |
double | value | Output value, 0 if the parameter does not exist |
Returns
Type | Description |
---|---|
bool | true if the parameter existed and had a non-null value of a compatible type |
TryGetIntValue(SoField, out int)
Try to retrieve the value of a parameter as an integer; this method will allow you to fetch an Int32 from what is actually an Int16, to make life easier.
Declaration
public bool TryGetIntValue(SoField argument, out int value)
Parameters
Type | Name | Description |
---|---|---|
SoField | argument | Which parameter to look for; the first field that matches the definition will be used |
int | value | Output value, 0 if the parameter does not exist |
Returns
Type | Description |
---|---|
bool | true if the parameter existed and had a non-null value of a compatible type |
Remarks
This method takes an SoField instead of a FieldInfo, so that you do not have to know the exact TableInfo instance of the field. On the other hand, if there is aliasing (multiple occurrences of fields from the same table, but different TableInfo instances), then you cannot distinguish between them and will get the first one.
TryGetIntValue(FieldInfo, out int)
Try to retrieve the value of a parameter as an integer; this method will allow you to fetch an Int32 from what is actually an Int16, to make life easier.
Declaration
public bool TryGetIntValue(FieldInfo argument, out int value)
Parameters
Type | Name | Description |
---|---|---|
FieldInfo | argument | Which parameter to look for |
int | value | Output value, 0 if the parameter does not exist |
Returns
Type | Description |
---|---|
bool | true if the parameter existed and had a non-null value of a compatible type |
TryGetStringValue(SoField, out string)
Try to retrieve the value of a parameter as a string.
Declaration
public bool TryGetStringValue(SoField argument, out string value)
Parameters
Type | Name | Description |
---|---|---|
SoField | argument | Which parameter to look for; the first field that matches the definition will be used |
string | value | Output value, 0 if the parameter does not exist |
Returns
Type | Description |
---|---|
bool | true if the parameter existed and had a non-null value of a compatible type |
Remarks
This method takes an SoField instead of a FieldInfo, so that you do not have to know the exact TableInfo instance of the field. On the other hand, if there is aliasing (multiple occurrences of fields from the same table, but different TableInfo instances), then you cannot distinguish between them and will get the first one.
TryGetStringValue(FieldInfo, out string)
Try to retrieve the value of a parameter as a string.
Declaration
public bool TryGetStringValue(FieldInfo argument, out string value)
Parameters
Type | Name | Description |
---|---|---|
FieldInfo | argument | Which parameter to look for, exact match required |
string | value | Output value, 0 if the parameter does not exist |
Returns
Type | Description |
---|---|
bool | true if the parameter existed and had a non-null value of a compatible type |