Show / Hide Table of Contents

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 ) );
Inheritance
Object
ArgumentParameterCollection
Implements
IEnumerable
ICloneable
Inherited Members
Object.Equals(Object)
Object.Equals(Object, Object)
Object.ReferenceEquals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
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
Int32

FieldInfos

Returns the FieldInfo-collection

Declaration
public ICollection FieldInfos { get; }
Property Value
Type Description
ICollection

Item[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

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
This hybrid deep/shallow copy is intended for cases where you need to work with a query in an asynchronous handler, while the client may be reusing it elsewhere. It assumes that FieldInfo and TableInfo objects are immutable, so they are not cloned. It also assumes that you will not need copies of BLOB parameters, this assumption is realized in Clone() where BLOB objects are NOT copied (they are streams and we do not wish to assume multiple access).

If you need more, you get the fun of implementing ICloneable wherever you need it :-)

CloneAndExtendWithEquivalents(TableInfo, Int32, FieldInfo[])

Clone the this, and check that all 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

Int32 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 . 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 , using the primary key . There will be at most one database access. All fields specified by must belong to the same table (SoTable) as the .

Exceptions
Type Condition
SoIllegalOperationException

Thrown if .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
Boolean

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
Boolean

HasSameField(FieldInfo)

Declaration
public bool HasSameField(FieldInfo argument)
Parameters
Type Name Description
FieldInfo argument
Returns
Type Description
Boolean

ToString()

Returns a String that represents the current Object.

Declaration
public override string ToString()
Returns
Type Description
String

A String that represents the current Object.

Overrides
Object.ToString()

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
Boolean

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
Boolean

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
Boolean

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
Boolean

true if the parameter existed and had a non-null value of a compatible type

TryGetIntValue(SoField, out Int32)

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

Int32 value

Output value, 0 if the parameter does not exist

Returns
Type Description
Boolean

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 Int32)

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

Int32 value

Output value, 0 if the parameter does not exist

Returns
Type Description
Boolean

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
Boolean

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
Boolean

true if the parameter existed and had a non-null value of a compatible type

Implements

System.Collections.IEnumerable
System.ICloneable

Extension Methods

EnumUtil.MapEnums<From, To>(From)
ObjectExtensions.AssignByReflection<T>(T, T)
ObjectExtensions.GraphCopy<T>(T)
Converters.MapEnums<From, To>(From)
© SuperOffice. All rights reserved.
SuperOffice |  Community |  Release Notes |  Privacy |  Site feedback |  Search Docs |  About Docs |  Contribute |  Back to top