QuickObjects.ObjectBase Send comments on this topic.
BaseBusinessObject Class Members
See Also  Properties  Methods  Events
Akal.QuickObjects.ObjectBase Namespace : BaseBusinessObject Class


The following tables list the members exposed by BaseBusinessObject.

Public Constructors

 NameDescription
Public ConstructorBaseBusinessObject ConstructorOverloaded. BaseBusinessObject

Default constructor offers no functionality. Calls the base constructor with same signature.  

Top

Public Properties

 NameDescription
Public PropertyAddResultsToDataSetAddResultsToDataSet

Holds the boolean value indicating weather the find method will try to add/refresh the result set into the dataset.  

Public PropertyAffectedRecords

AffectedRecords

Holds an Int32 value which can be used to hold the number of records that are either returned or affected by a query.

This can be very useful in cases where a count of returned rows is needed.


myLabel.Text = myBusinessObject.AffectedRecords.ToString() + " records were returned by your search";
(Inherited from Akal.QuickObjects.DBLibrary.DatabaseObject)
Public PropertyAutoEncloseObjectNamesAutoEncloseObjectNames

Indicates weather the business object will enclose the Field names and Table names with [ ] while running the SQL statement. By default this is set to false.

If you run a Find method on your object which has two fields called myField1, and myField2 and this property is set to true, your resulting SQL statement will look like SELECT [myField1], [myField2] From [myTable] (SQL Server) and for Oracle SELECT "myField1", "myField2" From "myTable".  

Public PropertyAutoRecursionAutoRecursion

Indicates weather at the time of creating a join with another business object, the Recursive property will be passed on to the joined object or not. The ability to override the Recursive property after a join has been created is still irrespective of this property's value.

If you create a join with a Parent object and current Recursive property is set to RecursionTypes.None, it will be automatically switched to RecursionTypes.Parent. However, if more than one type of join is created i.e. Parent and Child relationship, the property will be set to RecursionTypes.All.

NOTE: This property's Recursive property will be passed to the joined object at the time of creating the join. If you change the Recursive property later, the value will not be copied automatically.  

Public PropertyAutoSyncOnConnectIf AutoSyncOnConnect is set to true and the ObjectState property is changed from Disconnected to Connected, the Save method of the business object will be automatically called. If AutoSyncOnConnect is set to false, to synchronize all the changes made to the data locally will need to by synchronized by calling the Save method.  
Public PropertyCaseConversionCaseConversion

Used to determine if the business object will transform all its String field's case to Upper or Lower. By default the business object does not transform the String values held in the StringField's Value property.

It will reset the CaseConversion property of all the StringField objects held in the Fields collection with the passed in value.

NOTE: The conversion is only performed for Insert, Update statements and for any values being used in Search criteria. The Find method does not transform the field values returned from the database as this can severely affect the performance in case of a large result set being returned. Although Load method does not perform this conversion either but once the values are loaded into the StringField any values returned follow the CaseConversion property of that field.  

Public PropertyConcurrencyModeConcurrencyMode

Used to determine if the business object check to see if the underlying data in a row was changed while the data was being modified in the business object. By default the business object does not perform this check, and it merely overwrites the underlying row with the provided row to be updated. The same rule applies for Delete as well.  

Public PropertyConnectionString

ConnectionString

Holds the value for connection String used to make a connection to the target database.

This property is automatically initialized with the value from the application configuration settings. The value of ConnectionStringConfigName is used to look for the connection String from the application settings (AppSettings/Keys in Framework 1.1 and ConnectionSettings/Connections in Framework 2.0)..

This property can also be manually set to point the library to a database other than the default. This will be useful if you need the library to connect to multiple database.


myBusinessObj.ConnectionString = "Server=.\SQLExpress;Database=SqlSample;User ID=my_id;Password=my_pass;User Instance=false;
(Inherited from Akal.QuickObjects.DBLibrary.DatabaseObject)
Public PropertyConnectionStringConfigNameConnectionStringConfigName

Set this property to change the name of the connection String. By default the library looks for a "database" connection String (AppSettings/Keys in Framework 1.1 and ConnectionStrings in Framework 2.0). This property should be modified before the database connection is initiated. (Inherited from Akal.QuickObjects.DBLibrary.DatabaseObject)

Public PropertyDatabaseTypeConfigNameDatabaseTypeConfigName

Set this property to change the name of the AppSettings key that contains the database type information. By default the library looks for a "database_type" AppSettings key. (Inherited from Akal.QuickObjects.DBLibrary.DatabaseObject)

Public PropertyDBConnectionDBConnection

Holds any IDbConnection object. This is autmatically created based on the DBType selection.

If the DBType is set to SQL Server 2000 or SQL 2005, this property will be assigned a SqlConnection object, but if the DBType is set to Oracle 8i, 9i or 10g this property will be assigned an OracleConnection.

If you like to manually set the connection you can do so as well as Int64 as the underlying database type remains the same as the value of DBType.


myBusiessObj.DBType = DBTypes.Sql2005;
myBusinessObj.DBConnection = new SqlConnection();

Or


myBusinessObj.DBType = DBTypes.Oracle10g;
myBusinessObj.DBConnection = new OracleConnection();

NOTE: This property is not NonSerializable and it is also ignored during Xml Serialization. (Inherited from Akal.QuickObjects.DBLibrary.DatabaseObjectSQL)

Public PropertyDBTransaction

DBTransaction

Holds any IDbTransaction compatible object. This is autmatically created based on the value set in UseInTransaction property. If the UseInTransaction property is set to true, then at the time of creating a connection a new Transaction object will be created.

If you like to manually set the transaction object you can do so, although it is better to let the library handle the transaction object creation along with the connection object creation.


myBusinessObj.DBTransaction = myBusinessObj.DBConnection.BeginTransaction();

NOTE: This property is not NonSerializable and it is also ignored during Xml Serialization.

(Inherited from Akal.QuickObjects.DBLibrary.DatabaseObjectSQL)
Public PropertyDBTypeDBType

Specifies the uderlying database server that will be used by this library. (Inherited from Akal.QuickObjects.DBLibrary.DatabaseObject)

Public PropertyEdition ProductEditions - Returns the product edition being used currently.  
Public PropertyErrorStringOverridden. 

ErrorString

Holds a String value. This value is used to store the errors that were encountered while working with any of the database objects. Note: Starting with version 3.x this property also returns any validation errors on the fields as well. Each error message is seperated by a line break. Also, if you try to set a blank/null value then all the Validators's error messages are set to null as well.


myErrLabel.Text = this.ErrorString;
 
Public PropertyFieldsFields

Holds a collection of IField type fields.  

Public PropertyFillSchemaFillSchema

Value of FillSchema determines weather after running a SELECT statement if the FillSchema method will be called to fill the underlying schema into the dataset.

NOTE: This is set to false by default. (Inherited from Akal.QuickObjects.DBLibrary.DatabaseObjectSQL)

Public PropertyHasChanges Returns true if any of the rows stored in the ResultSet have been added/modified or deleted.  
Public PropertyIncludeTableNameIncludeTableName

Holds a boolean value.

This value indicates weather the query to run the search will prefix the table name to the field names. This should be set to true if you are using multiple tables and more than one table might be using same column names, as this will avoid the conflict.  

Public PropertyIsDirty

IsDirty

Holds a boolean value. This value indicates weather the record values loaded into the object's properties have been modified since then or not.

Setting the value to false also resets the IsDirty flag on all the fields contained by this business object.


	if (myBusinessObject.IsDirty)
	{
		//codeBlock
	}
	

As in the above example, IsDirty property can be used to determine weather the record values loaded have been modified or not and IsDirty can be combined with IsLoaded to check if the record has been loaded or not.

 
Public PropertyIsLoaded

IsLoaded

Holds a boolean value. This value indicates weather the record values have been loaded into the object's properties.


	if (myBusinessObject.IsLoaded)
	{
		//codeBlock
	}
	

As in the above example, IsLoaded property can be used to determine weather the record values have been loaded or not. Also it can be combined with the IsDirty property to see if the values have been changed since they were last loaded.

 
Public PropertyIsValid Validates each field and returns true if all fields are valid and false if any field's validation fails. NOTE: Calling IsValid method will put all the errors from all the failing validators into the ErrorString property and each error message will be seperated by a line break.  
Public PropertyJoinsJoins

Holds a JoinCollection value. This value is used to indicate the joins with other business objects weather the relationship is parent or child to this object.  

Public PropertyLocalTimeZoneLocalTimeZone

This allows the business object to perform calculations on Dates and convert the UTC dates to the local dates and times of the User.

It will reset the LocalTimeZone property of each DateTimeField with the passed in value.  

Public PropertyLoggedInUserLoggedInUser

Useful for ASP.NET based applications as this property is this value is initialized from the Session variable UserID. If your application does contain a field in the Session called UserID then that value is easily available from LoggedInUser property.

NOTE: It is not initialized if the library is being used in any other type of environment other than ASP.NET.  

Public PropertyMaxRecordsMaxRecords

Holds an Int32 value.

This value indicates the number of maximum rows the search will return. If this value is set to -1 (by default) all rows will be returned. It is implemented for all database types.  

Public PropertyMaxRecursionLevelsMaxRecursionLevels

Stores the maximum levels for the business object to traverse while running various commands.

This however will have no effect if the Recursive property is set to None. Also, this property is used from the first business object that is used to run any operation.  

Public PropertyMoreResults

MoreResults

Holds a boolean value. This value is used when searching for records to determine weather to use " AND " clause or " OR " clase between the criteria.


	myBusinessObject.MoreResults = true;
	

As in the above example, when searching for records more results will be return.

 
Public PropertyObjectMode

ObjectMode

If ObjectMode is set and a value is assigned to any type of Field the field's UseInSave or UseInSearch flags are set based on the ObjectMode.

If ObjectMode is set to Search then UseInSearch is set to true. However if the ObjectMode is set to Save then UseInSave is set to true.


	myBusinessObj.ObjectMode = ObjectModes.Search;
	myBusinessObj.myIDField.Value = 1;
	myBusinessObj.myNameField.Value = "JOHN";
	

This will set the myIDField.UseInSearch and myNameField.UseInSearch to true automatically.

 
Public PropertyObjectState ObjectState property is used by the business object to know if the business object should send all the commands to the database or should retain all changes locally to be synchronized at a later time.  
Public PropertyOnlyDistinctOnlyDistinct

Holds a boolean value.

This value indicates weather the search results will return only distinct rows. This is acheived by adding DISTINCT keyword to the select statement.  

Public PropertyPageSizePageSize

Holds an Int32 value.

This combined with the StartRowIndex property can be used to create a paged view of the result set.

NOTE: This feature is not implemented for SQL Server 2000. If you are using SQL Server 2000 as your data store you will need to write your own paged result set sql statements and use the DatabaseObjectSQL methods to run those.  

Public PropertyParameterPrefix ParameterPrefix - Returns the prefix that can be used to prefix the parameter names (Inherited from Akal.QuickObjects.DBLibrary.DatabaseObjectSQL)
Public PropertyPartialTextMatch

PartialTextMatch

Holds a boolean value. This value is used when searching for records to determine weather match the text columns with partial values or exact values. Setting this value reset's all the StringField's PartialTextMatch property as well.


	myBusinessObject.PartialTextMatch = true;
	

As in the above example, when searching for records any records that contain the text will be returned.

 
Public PropertyPrimaryKeyFieldsPrimaryKeyFields

Holds a collection of IField type fields that make up the Primary key for this business objects tables.  

Public PropertyRecursiveRecursive

Stores the direction in which the business object will traverse while running various commands.

This however will have no effect if the MaxRecursionLevels property is set to 0. Also, this property is used each business object that is joined to the original business object running the operation.  

Public PropertyResultSetResultSet

Holds the DataSet for the result sets.

The Load method will add the returned row to a table in this data set, and if it loads any parent or child records, those will be added in seperate tables.

The Find method will add the returned row(s) to a table (named as TableName or ResultSetName property - Use the GetResultSetName method).

Note: Only if the AddResultsToDataSet is true the results will be added to this DataSet.  

Public PropertyResultSetNameResultSetName

Holds the NameField value that will be used by the find method to Add/Refresh the table in the dataSet.  

Public PropertySessionEndCommandSessionEndCommand

Holds a SQL command String or the name of the stored procedure that is executed at the time database connection is closed/destroyed. Hence if the connection is shared by multiple objects, the command is only run once. (Inherited from Akal.QuickObjects.DBLibrary.DatabaseObjectSQL)

Public PropertySessionEndCommandTypeSessionEndCommandType

Holds a CommandType that indicates weather the SessionEndCommand is of type Text or Stored Procedure. TableDirect command type is not supported. (Inherited from Akal.QuickObjects.DBLibrary.DatabaseObjectSQL)

Public PropertySessionEndParametersSessionEndParameters

Holds either a Hashtable or an ArrayList of IDataParameters. If a Hashtable is assigned it should contain Key and Value pairs for parameters that the SessionStartCommand expects. Using a hashtable the stored procedure can not return any values and only inbound parameters can be used.

If a ArrayList of parameter objects is used the ArrayList should contain an instance of parameter object for each parameter that SessionStartCommand expects. The parameter objects can be both inbound or outbound and may be of any data type that the underlying database supports.

NOTE: To create an instance of the parameter of type that is suitable for your currently selected database type, call the GetNewParameterInstance method of this object. For example: IDataParameter param = databaseObjectSQL.GetNewParameterInstance();

By using the GetNewParameterInstance you are not hard coding the database specific parameter type, hence if you ever decide to move the underlying data store to a different data store (e.g. move from SQL Server to Oracle or vice versa), you will NOT need to recompile and the application will continue to work. (Inherited from Akal.QuickObjects.DBLibrary.DatabaseObjectSQL)

Public PropertySessionStartCommandSessionStartCommand

Holds a SQL command String or the name of a stored procedure that is executed at the time database connection is created. Hence if the connection is shared by multiple objects, the command is only run once. (Inherited from Akal.QuickObjects.DBLibrary.DatabaseObjectSQL)

Public PropertySessionStartCommandTypeSessionStartCommandType

Holds a CommandType that indicates weather the SessionStartCommand is of type Text or Stored Procedure. TableDirect command type is not supported. (Inherited from Akal.QuickObjects.DBLibrary.DatabaseObjectSQL)

Public PropertySessionStartParametersSessionStartParameters

Holds either a Hashtable or an ArrayList of IDataParameters. If a Hashtable is assigned it should contain Key and Value pairs for parameters that the SessionStartCommand expects. Using a hashtable the stored procedure can not return any values and only inbound parameters can be used.

If a ArrayList of parameter objects is used the ArrayList should contain an instance of parameter object for each parameter that SessionStartCommand expects. The parameter objects can be both inbound or outbound and may be of any data type that the underlying database supports.

NOTE: To create an instance of the parameter of type that is suitable for your currently selected database type, call the GetNewParameterInstance method of this object. For example: IDataParameter param = databaseObjectSQL.GetNewParameterInstance();

By using the GetNewParameterInstance you are not hard coding the database specific parameter type, hence if you ever decide to move the underlying data store to a different data store (e.g. move from SQL Server to Oracle or vice versa), you will NOT need to recompile and the application will continue to work. (Inherited from Akal.QuickObjects.DBLibrary.DatabaseObjectSQL)

Public PropertyStartRowIndexStartRowIndex

Holds an Int32 value.

This combined with the PageSize property can be used to create a paged view of the result set.  

Public PropertyTableNameTableName

Holds a NameField value.

This value is used to indicate the table the object is will be performing its operations on.  

Public PropertyTranslateTimeZonesTranslateTimeZones

Used to determine if the business object will translate the datetime field's value to UTC before saving to DB. The process will use the LocalTimeZone value to determine the time difference when reading and writing to the database.

It will reset all the DateTime field's TranslateTimeZones with the value of TranslateTimeZones  

Public PropertyUseNoLockUseNoLock

Holds a boolean value.

This value indicates weather the select query will use the nolock clause or not.

NOTE: This is only used when the database server is SQL Server 2005 or SQL Server 2000.  

Public PropertyUseTransaction

UseTransaction

Value of UseTransaction determines weather this object will create a Transaction at the time of creating database connection.

If UseTransaction is set to true, and AssignConnection method is used to create joined objects, the connection, transaction are automatically shared by each business object. This allows multiple business objects to run various commands under the same transaction scope.


myBusinessObj.UseTransaction = true;

NOTE: This property is set to false by default, and hence for the business object to run various commands in a transaction, this property must be explicitely set to true.

(Inherited from Akal.QuickObjects.DBLibrary.DatabaseObjectSQL)
Public PropertyVisibleVisible

Holds a boolean value. This value indicates weather the search results will show the columns of this table. This value overrides all the Visible properties of columns of this table.

NOTE: Setting this property does not reset any of the field's Visible property. If this is set to false, the field's Visible property has no effect.  

Top

Public Methods

 NameDescription
Public MethodAssignConnection

AssignConnection

If the current instance does not have an instance of database connection object, then this method calls CreateConnection method. After that the reference to the existing database connection object stored in DBConnection is passed to the passed in Object's DBConnection member variable.

If the current instance's UseTransaction is set to true then this method also passes the reference to the existing transaction object stored in DBTransaction to the passed in Object's DBTransaction member variable.

This method also assigns the SessionStartCommand and SessionEndCommands allowing any of the connected business objects to be able to run the SessionStartCommand and SessionEndCommand at the time of database connection opening and closing.

Parameters:
Description
dbObjDatabaseObjectSQL instances that will receive the DBConnection and DBTransaction values.


	this.AssignConnection(databaseObjectToJoin);
	
(Inherited from Akal.QuickObjects.DBLibrary.DatabaseObjectSQL)
Public MethodAverageAverage

Gets the average value of the passed in field from the database that match the criteria (if any provided). The value is returned in the same field object.

This method will in addition set the AffectedRecords property with the number of records returned by this method.

If the ObjectState is Disconnected this method will return false.

Returns:
Type
System.Boolean
 

Public MethodCommitTransaction CommitTransaction

Commits the active SQL Transaction held in DBTransaction member variable, and then Disposes the transaction object, closes the connection object and sets it to null.

NOTE: This however does not affect your ability to run more commands to the underlying database using the same instance of the database object instance as the database object creates a new connection when trying to run a new command after the earlier connection has been closed.

(Inherited from Akal.QuickObjects.DBLibrary.DatabaseObjectSQL)
Public MethodCountCount

Gets the count of records in the database that match the criteria (if any provided).

This method will in addition set the AffectedRecords property with the number of records returned by this method.

If the ObjectState is Disconnected this method will return the count of rows in the ResultSet for this objects corrosponding table.

Returns:
Type
System.Int32
 

Public MethodCreateConnection

CreateConnection

Creates a database connection and sets the DBConnection property.

Depending on the DBType value either a SqlConnection object is created and stored in DBConnection property or an OracleConnection object is created and stored. If the DBConnection already has a connection object then this method does not create a new instance, instead it simply ensures that the connection is open.

Also, if the UseTransaction property is set to true, then a new transaction object is created at the time of creating a connection.

If there are any exceptions during connection or transaction object creation, the ErrorString property is populated with the exception message.


	dbObj.CreateConnection();
	
(Inherited from Akal.QuickObjects.DBLibrary.DatabaseObjectSQL)
Public MethodCreateJoinOverloaded. CreateJoin

Used to create a join with another business object, and also to specify the JoinType along with the RelationshipType. After creating a join with the passed in business object, the Join reference is added to the Joins collection.

ObjectMode, ObjectState, AutoSyncOnConnect, ConcurrencyMode, ResultSet, MoreResults and PartialTextMatch properties values are automatically assigned to the newly joined object. This ensures that the joined business objects function just like the main business object.

Parameters:
Description
nameName for the join.
leftFieldThis field must belong to this business object that is executing this method.
rightFieldThis field must belong to the passed in business object that will be used to create the join.
joinObjectBusiness object that will be used to create a join.
joinTypeJoinType to be used for creating a new Join. Ex: JoinTypes.Inner or JoinTypes.Left
relationRelationshipType with the passed in business object. If the passed in business object holds parent records then RelationshipTypes.Parent should be used otherwise RelationshipTypes.Child should be used.

Returns:
Type
Join
 

Public MethodDeleteOverloaded. Delete

Runs a Delete command to delete the record whose primary key values match the PrimaryKeyFields values. This method expects that all the primary key values have been specified.

No recursive action is taken on the joined objects. Each object's Delete method must be called to delete the related records as well.

This method will reset the AffectedRecords property to the number of rows deleted.

Business object must have at least one primary key field defined for this operation to work.

NOTE: As of version 3.x this method preserves each field's UseInSearch values, and does not reset any of the property values unlike the version 2.x and older did. Also starting version 3.x this method will retain any information related to any records deleted that can be a later applied to the database. If the ObjectState property is set to Connected then the Delete command is sent to the database immediatly.

Returns:
Type
System.Boolean
 

Public MethodDispose Dispose

Effective version 3.x this method overrides the DatabaseObjectSQL class's Dispose method, and it is used to fire the ObjectDisposing event.

 
Public MethodFindOverloaded. Find

Performs a search on all the fields of this object or any joined object that are marked with UseInSearch as true and AllowSearch is also set to true.

The returned result set will only contain the fields and business objects whose Visible property is set to true.

If the OnlyDistinct property is set then the result set will only contain distinct rows.

Any Fields that have their Sort property set will be included in the sorting of the result set as per their SortPosition property.

AddResultsToDataSet will determine if the data returned from the execution of this command will be added into the DataSet held at ResultSet property.

If the ObjectState property is set to Disconnected then this method will not connect to the database and will not return any data.

Passed in values of startRow and rowCount parameters will be used to set the StartRowIndex and PageSize properties in order to return a paged result set.

NOTE: Paged result set is not supported on SQL Server 2000.

Parameters:
Description
startRow
rowCount

Returns:
Type
DataSet
 

Public MethodFindAndLoadFindAndLoad

Essentially the same as calling the Find method, except that FindAndLoad will load the first row from the returned result set.

This can also be very useful for finding unique or non-unique records that without the knowledge of their primary key value but finding them on the basis of other field values.

This method will set the AffectedRecords property with the number of records returned by Find method.

NOTE: As of version 3.x this method will not return any data if the ObjectState property is set to Disconnected.

Returns:
Type
System.Boolean
 

Public MethodGetDeleteSQLGetDeleteSQL

Creates an DELETE SQL Statement suitable for the selected DatabaseType. This method expects that all the primary key values have been specified.

NOTE: As of version 3.x this method preserves each field's UseInSearch values, and does not reset any of the property values unlike the version 2.x and older did.

Parameters:
Description
sqlParamsAll the parameters created by this method will be added into this ArrayList.

Returns:
Type
System.String
 

Public MethodGetDelimetedValueOverloaded. GetDelimetedValue

Goes through all records in an array of DataRows and adds all the values for the field into a delimited String where each value is separated by passed in value of delimit parameter.

Parameters:
Description
drsAn array of DataRows that contain the field whose value will be used to created the delimited String.
fieldfield that must exist in each DataRow.
delimitString value that will be used as a separator between each field value.

Returns:
Type
System.String
 

Public MethodGetFieldsListOverloaded. GetFieldsList

Provides a String of field names separated by a comma for this object and any joined objects. The Recursive property on this objects and on the joined objects determine if the joined objects will also try to create a field list from their joined objects to be included in this field list. This process will follow until the depth reaches maxLevel parameter value.

NOTE: If the IncludeTableName property of this or any joined object is set to true, that business object's field names will be prefixed with their table name.

Parameters:
Description
levelCurrent level in recursion.
maxLevelsMaximum levels of business objects to cover during recursion.
objectsCoveredA collection that can be used to track what business objects are already covered.

Returns:
Type
System.String
 

Public MethodGetFromExpressionGetFromExpression

Provides a String that can be used as a From portion of the SQL statement. This includes the table name and an alias (ResultSetName if it is set as well and different from Name property)

Returns:
Type
System.String
 

Public MethodGetGroupByExpressionOverloaded. GetGroupByExpression

Provides a String of field names to be included in the Group By clause separated by comma for this object and any joined objects. The Recursive property on this objects and on the joined objects determine if the joined objects will also try to add fields into the group by clause. This process will follow until the depth reaches maxLevel parameter value.

Parameters:
Description
levelCurrent level in recursion.
maxLevelsMaximum levels of business objects to cover during recursion.
objectsCoveredA collection that can be used to track what business objects are already covered.
groupByFieldsA collection that is used to add all the fields that will be used to build the group by expression.

Returns:
Type
System.String
 

Public MethodGetInsertExpressionGetInsertExpression

Provides a String that contains a list of all the fields that can be used in an INSERT statement. A field must have its AllowSave and UseInSave as true to be included.

Parameters:
Description
sqlParamsAll the parameters created by this method will be added into this ArrayList.

Returns:
Type
System.String
 

Public MethodGetInsertSQLGetInsertSQL

Creates an INSERT SQL Statement suitable for the selected DatabaseType. The SQL Statement will contain all the fields that are marked UseInSave as true. This method expects that all the primary key values have been specified if they are not marked as AutoGenerated.

Parameters:
Description
sqlParamsAll the parameters created by this method will be added into this ArrayList.

Returns:
Type
System.String
 

Public MethodGetJoinExpressionOverloaded. GetJoinExpression

Provides a Join expression of all joined objects in a String. It uses the Recursive property on this objects and on the joined objects determine if the joined objects will also try to create joins with their joined objects. This process will follow until the depth reaches maxLevel parameter value.

Parameters:
Description
levelCurrent level in recursion.
maxLevelsMaximum levels of business objects to cover during recursion.
objectsCoveredA collection that can be used to track what business objects are already covered.

Returns:
Type
System.String
 

Public MethodGetNewParameterInstance

GetNewParameterInstance

Returns a new instance of parameter object that is suitable to be used with the currently selected DatabaseType.


		IDataParameter param =
        databaseObjectSQL.GetNewParameterInstance();
		param.Name = "myParamName";
	
(Inherited from Akal.QuickObjects.DBLibrary.DatabaseObjectSQL)
Public MethodGetOriginalWhereExpressionGetOriginalWhereExpression

Provides a String comprised of all the field's search expressions based on their original values. Each field's search expression is obtained if it is marked as Visible or UseInSave.

Parameters:
Description
includeTableNameIf true then each field name will be have its table name prefixed. This is important and useful when creating where expression from multiple tables and more than one table may contain the same column name.
recurRecursion type that will determine what kind of joined objects will be covered. If Recursion is set to RecursionTypes.Parent then only the Join objects with relationship type of Parent will be covered and hence same process for Child relationship.
levelCurrent level in recursion.
maxLevelsMaximum levels of business objects to cover during recursion.
objectsCoveredA collection that can be used to track what business objects are already covered.
sqlParamsAll the parameters created by this method will be added into this ArrayList.

Returns:
Type
System.String
 

Public MethodGetResultSetNameGetResultSetName

Compares the Name property with ResultSetName property and returns ResultSetName if it is different from Name property.

Returns:
Type
System.String
 

Public MethodGetSelectSQLGetSelectSQL

Creates a SQL Statement suitable for the selected DatabaseType. The SQL Statement will contain all the fields in its fields list that are marked Visible including any joined object's fields where both the joined object and the fields are marked Visible.

The where clause will be created any fields that are marked with UseInSearch as true and AllowSearch is also set to true. This includes fields from any joined objects.

If the OnlyDistinct property is set then the return SQL statement will include DISTINCT clause.

Any Fields that have their Sort property set will be included in the sort expression of the SQL statement in the order of their SortPosition property.

If the values of StartRowIndex and PageSize properties have been set then the returned SQL statement will contain appropriate code to created a paged result set.

NOTE: Paged result set is not supported on SQL Server 2000.

Parameters:
Description
sqlParamsAll the parameters created by this method will be added into this ArrayList.

Returns:
Type
System.String
 

Public MethodGetSortExpressionOverloaded. GetSortExpression

Provides a String of field names with their sort order separated by comma for this object and any joined objects. The Recursive property on this objects and on the joined objects determine if the joined objects will also try to create sort expressions from their joined objects. This process will follow until the depth reaches maxLevel parameter value.

Parameters:
Description
levelCurrent level in recursion.
maxLevelsMaximum levels of business objects to cover during recursion.
objectsCoveredA collection that can be used to track what business objects are already covered.
sortFieldsA collection that is used to add all the fields that will be used to build the sort expression.

Returns:
Type
System.String
 

Public MethodGetSQLExceptionAsStringGetSQLExceptionAsString

Gets detailed error message and the source of the passed in Exception.

Parameters:
Description
sqExException instance to use for returning an error message.
(Inherited from Akal.QuickObjects.DBLibrary.DatabaseObjectSQL)

Public MethodGetStringsFromColumnGetStringsFromColumn

Goes through all records in a DataRowCollection and adds all the values for the field name into an array of strings.

Returns:
Type
System.String[]
 

Public MethodGetUpdateExpressionGetUpdateExpression

Provides a String that contains a list of all the fields including their parameter names. A field must have its AllowSave and UseInSave as true to be included.

Parameters:
Description
sqlParamsAll the parameters created by this method will be added into this ArrayList.

Returns:
Type
System.String
 

Public MethodGetUpdateSQLGetUpdateSQL

Creates an UPDATE SQL Statement suitable for the selected DatabaseType. The SQL Statement will contain all the fields that are marked UseInSave as true. This method expects that all the primary key values have been specified.

NOTE: As of version 3.x this method preserves each field's UseInSearch values, and does not reset any of the property values unlike the version 2.x and older did.

Parameters:
Description
sqlParamsAll the parameters created by this method will be added into this ArrayList.

Returns:
Type
System.String
 

Public MethodGetValueListOverloaded. GetValueList

Provides a String that contains a list of all the field's values separated by a comma. A field must have its Visible property as true to be included.

Returns:
Type
System.String
 

Public MethodGetWhereExpressionOverloaded. GetWhereExpression

Provides a String comprised of all the field's search expressions. Each field's search expression is obtained based on its AllowSearch, UseInSearch and SearchMode properties. See GetWhereExpression method of the BaseField class for more information on how each field's search expression is created. Each field's search expression is separated by either AND or an OR clause depending the MoreResults property on this business object. If MoreResults is set to true then OR is used otherwise AND is used, this however can be overridden at each field level as well by setting the Field's SearchCondition property. The Recursive property on this objects and on the joined objects determine if the joined objects will also try to create their own search expressions from their joined objects to be include in this expression. This process will follow until the depth reaches maxLevel parameter value.

Parameters:
Description
includeTableNameIf true then each field name will be have its table name prefixed. This is important and useful when creating where expression from multiple tables and more than one table may contain the same column name.
levelCurrent level in recursion.
maxLevelsMaximum levels of business objects to cover during recursion.
objectsCoveredA collection that can be used to track what business objects are already covered.
sqlParamsAll the parameters created by this method will be added into this ArrayList.

Returns:
Type
System.String
 

Public MethodInitializeObjectInitializeObject

Loads all the default values from the configuration file. This method only needs to be called once during the lifetime of the business object. This method can be overridden from any of the inheriting classes. This can be useful if you have a need to store the default values in a different configuration store. For example, you can store the default values for the configurable properties in database, external xml or text file or any other storage of your choice and you can override this method and perform reading of values and supplying the read values into the configurable properties of this object.  

Public MethodInsertOverloaded. Insert

Runs an Insert command with the fields marked with UseInSave as true. This method expects that all the primary key values have been specified if they are not marked AutoGenerated.

If the underlying database is Oracle then this method will also load back values of the AutoGenerated PrimaryKeyFields for the inserted record.

However, if the underlying database is SQL Server the value of the identity field is loaded automatically after insertion.

NOTE: Only one AutoGenerated primary key field is supported per business object when the underlying database is SQL Server 2000 or SQL Server 2005. If you have more than one AutoGenerated primary key fields, the insert will still work but the IDENTITY and/or other primary key field values will not be loaded back automatically.

Business object must have at least one primary key field defined for this operation to work.

NOTE: Starting version 3.x this method will retain any inserted values for a later sync/save process if the ObjectState property is set to Disconnected. If the ObjectState property is set to Connected then the Insert command is sent to the database immediatly.

Returns:
Type
System.Boolean
 

Public MethodLoadLoad

Loads all the field's values with values from the database for the specified primary key column values.

You must specify value for each primary key column in the PrimaryKeyFields collection.

If the ObjectState value is set to Disconnected then this method will try to load the values from the data stored in the ResultSet property. This method will try to find a row that matches the primary key values from the data set and will not initiate a call to the database. This can be useful if the data set is being populated from a different source than a database, i.e. a web service or an xml file etc. This is only application starting version 3.x which introduced the object's disconnected model.

NOTE: This will automatically switch the UseInSearch property on all Fields to false except the PrimaryKeyFields, as they will be set to true. Also, the IsLoaded property will be set to true if the function was able to load the values.

Returns:
Type
System.Boolean
 

Public MethodLoadChildLoadChild

Calls the Load method on the passed in child business object contained in the join.JoinedObject.

Parameters:
Description
join

Returns:
Type
System.Boolean
 

Public MethodLoadFromDataRowLoadFromDataRow

Loads all the field's values with values from the data row with matching column names.

Parameters:
Description
dataRow

Returns:
Type
System.Boolean
 

Public MethodLoadOriginalFromDataRowLoadOriginalFromDataRow

Loads all the field's values with values from the data row with matching column names into the OriginalFields collection.

Parameters:
Description
dataRow

Returns:
Type
System.Boolean
 

Public MethodLoadOriginalFromHashtableLoadOriginalFromHashtable

Loads all the field's original values with values from the Hashtable with matching column names into the OriginalFields collection.

Parameters:
Description
originalValues

Returns:
Type
System.Boolean
 

Public MethodLoadParentLoadParent

Calls the Load method on the passed in parent business object contained in the join.JoinedObject.

Parameters:
Description
join

Returns:
Type
System.Boolean
 

Public MethodMaximumMaximum

Gets the maximum value of the passed in field from the database that match the criteria (if any provided). The value is returned in the same field object.

This method will in addition set the AffectedRecords property with the number of records returned by this method.

If the ObjectState is Disconnected this method returns false.

Returns:
Type
System.Boolean
 

Public MethodMinimumMinimum

Gets the minimum value of the passed in field from the database that match the criteria (if any provided). The value is returned in the same field object.

This method will in addition set the AffectedRecords property with the number of records returned by this method.

If the ObjectState is Disconnected this method returns false.

Returns:
Type
System.Boolean
 

Public MethodReturn_bool Return_bool

If the passed in parameter is null, this method returns a false value. If the passed in object is not null, this method casts the object to a Boolean value and returns the result.

NOTE: This method is marked for deletion, please do not use. This method will be removed after two major releases. Please modify any references you may have to these methods and use the corresponding method in Utilities class.

 
Public MethodReturn_byte Return_byte

If the passed in parameter is null, this method returns a 0 (zero). If the passed in object is not null, this method casts the object to a Int16 value and returns the result.

NOTE: This method is marked for deletion, please do not use. This method will be removed after two major releases. Please modify any references you may have to these methods and use the corresponding method in Utilities class.

 
Public MethodReturn_DateTime Return_DateTime

If the passed in parameter is null, this method returns the minimum value supported by the DateTime object as the value. If the passed in object is not null, this method casts the object to a DateTime value and returns the result.

NOTE: This method is marked for deletion, please do not use. This method will be removed after two major releases. Please modify any references you may have to these methods and use the corresponding method in Utilities class.

 
Public MethodReturn_decimal Return_decimal

If the passed in parameter is null, this method returns a 0 (zero). If the passed in object is not null, this method casts the object to an Decimal value and returns the result.

NOTE: This method is marked for deletion, please do not use. This method will be removed after two major releases. Please modify any references you may have to these methods and use the corresponding method in Utilities class.

 
Public MethodReturn_double Return_double

If the passed in parameter is null, this method returns a 0 (zero). If the passed in object is not null, this method casts the object to an Double value and returns the result.

NOTE: This method is marked for deletion, please do not use. This method will be removed after two major releases. Please modify any references you may have to these methods and use the corresponding method in Utilities class.

 
Public MethodReturn_int Return_int

If the passed in parameter is null, this method returns a 0 (zero). If the passed in object is not null, this method casts the object to an Int32 value and returns the result.

NOTE: This method is marked for deletion, please do not use. This method will be removed after two major releases. Please modify any references you may have to these methods and use the corresponding method in Utilities class.

 
Public MethodReturn_long Return_long

If the passed in parameter is null, this method returns a 0 (zero). If the passed in object is not null, this method casts the object to a Int64 value and returns the result.

NOTE: This method is marked for deletion, please do not use. This method will be removed after two major releases. Please modify any references you may have to these methods and use the corresponding method in Utilities class.

 
Public MethodReturn_short Return_short

If the passed in parameter is null, this method returns a 0 (zero). If the passed in object is not null, this method casts the object to a Int16 value and returns the result.

NOTE: This method is marked for deletion, please do not use. This method will be removed after two major releases. Please modify any references you may have to these methods and use the corresponding method in Utilities class.

 
Public MethodReturn_string Return_string

If the passed in parameter is null, this method returns a "" (blank String). If the passed in object is not null, this method casts the object to a String value and returns the result.

NOTE: This method is marked for deletion, please do not use. This method will be removed after two major releases. Please modify any references you may have to these methods and use the corresponding method in Utilities class.

 
Public MethodReturn_uint Return_uint

If the passed in parameter is null, this method returns a 0 (zero). If the passed in object is not null, this method casts the object to a UInt32 value and returns the result.

NOTE: This method is marked for deletion, please do not use. This method will be removed after two major releases. Please modify any references you may have to these methods and use the corresponding method in Utilities class.

 
Public MethodReturn_ulong Return_ulong

If the passed in parameter is null, this method returns a 0 (zero). If the passed in object is not null, this method casts the object to a UInt64 value and returns the result.

NOTE: This method is marked for deletion, please do not use. This method will be removed after two major releases. Please modify any references you may have to these methods and use the corresponding method in Utilities class.

 
Public MethodReturn_ushort Return_ushort

If the passed in parameter is null, this method returns a 0 (zero). If the passed in object is not null, this method casts the object to a UInt16 value and returns the result.

NOTE: This method is marked for deletion, please do not use. This method will be removed after two major releases. Please modify any references you may have to these methods and use the corresponding method in Utilities class.

 
Public MethodReturn_XmlDocument Return_XmlDocument

If the passed in parameter is null, this method returns the minimum value supported by the XmlDocument object as the value. If the passed in object is not null, this method casts the object to a XmlDocument value and returns the result.

NOTE: This method is marked for deletion, please do not use. This method will be removed after two major releases. Please modify any references you may have to these methods and use the corresponding method in Utilities class.

 
Public MethodRollBackTransactionRollBackTransaction

Performs a RollBack on the active SQL Transaction held in DBTransaction member variable, and then Disposes the transaction object, closes the connection object and sets it to null.

(Inherited from Akal.QuickObjects.DBLibrary.DatabaseObjectSQL)
Public MethodRunSessionEndCommand

RunSessionEndCommand

Runs the command specified in the SessionEndCommand property. It is not necessary to call this method as the SessionEndCommand is automatically run when the database connection object is being disposed. This method is however provided for convenience in case you need to run this command several times in a session.

All parameters assigned to the SessionEndParameters are also used to provide parameters to the command as well.


	databaseObjectSQL.RunSessionEndCommand();
	
(Inherited from Akal.QuickObjects.DBLibrary.DatabaseObjectSQL)
Public MethodRunSessionStartCommand

RunSessionStartCommand

Runs the command specified in the SessionStartCommand property. It is not necessary to call this method as the SessionStartCommand is automatically run when the database connection is opened. This method is however provided for convenience in case you need to run this command several times in a session.

All parameters assigned to the SessionStartParameters are also used to provide parameters to the command as well.


	databaseObjectSQL.RunSessionStartCommand();
	
(Inherited from Akal.QuickObjects.DBLibrary.DatabaseObjectSQL)
Public MethodRunSPReturnDataReaderRunSPReturnDataReader

This method runs a Stored procedure and returns a data reader object

Parameters:
Description
procNameSQL Stored procdeure name to be executed.
parameterValuesAn array of objects to be assigned as the input values of the stored procedure.

Returns:
Type
IDataReader
(Inherited from Akal.QuickObjects.DBLibrary.DatabaseObjectSQL)

Public MethodRunSPReturnDatasetOverloaded. RunSPReturnDataset

This method runs a Stored procedure and returns a dataset.

Parameters:
Description
procNameSQL Stored procdeure name to be executed.
parameterValuesAn array of objects to be assigned as the input values of the stored procedure.

Returns:
Type
System.Data.DataSet
(Inherited from Akal.QuickObjects.DBLibrary.DatabaseObjectSQL)

Public MethodRunSPWithNoReturnOverloaded. RunSPWithNoReturn

This method runs a Stored procedure and does not return any result set

Parameters:
Description
procNameSQL Stored procdeure name to be executed.

Returns:
Type
System.Int32
(Inherited from Akal.QuickObjects.DBLibrary.DatabaseObjectSQL)

Public MethodRunSQLReturnDatasetOverloaded. RunSQLReturnDataset

This method runs a SQL Command and returns a dataset.

Parameters:
Description
sqlCommandSQL command to be executed.

Returns:
Type
System.Data.DataSet
(Inherited from Akal.QuickObjects.DBLibrary.DatabaseObjectSQL)

Public MethodRunSQLWithNoReturnOverloaded. RunSQLWithNoReturn

This method runs a SQL Command and returns the number of records affected.

Parameters:
Description
sqlCommandSQL command to be executed.

Returns:
Type
System.Int32
(Inherited from Akal.QuickObjects.DBLibrary.DatabaseObjectSQL)

Public MethodSaveSave method can be used to synchronize any changes made to this object or its related objects. If the current ObjectState is set to Disconnected, calling Save method will change the object state to "Connected" and the Save method will attempt to send all inserts/updates/deletes locally held to the database.

Save method also tries to save any of the related/joined object's locally held changes. If the UseTransaction property is set to true, any records failure will cause the transaction to be rolled back. If all records/changes have been saved correctly without any errors/exceptions then the transaction will be automatically committed. If however the UseTransaction property is set to false then the ErrorString property will be populated with errors for each row that failed.  

Public MethodSetDatabaseType

SetDatabaseType

Takes a String as the parameter and sets the DBType property with the type of database to which this object will be connecting.

Parameters:
Description
dBType

Sets the DBType property value with the value passed in.

Possible values for passing to this method are:

SqlServer2000

SqlServer2005

Oracle8i

Oracle9i

Oracle10g


myBusinessObj.SetDatabaseType("SqlServer2005");
(Inherited from Akal.QuickObjects.DBLibrary.DatabaseObject)
Public MethodSetSqlParamType SetSqlParamType - This method can be used to set the appropriate DBType property of the parameter. (Inherited from Akal.QuickObjects.DBLibrary.DatabaseObjectSQL)
Public MethodSumSum

Gets the sum value of the passed in field from the database that match the criteria (if any provided). The value is returned in the same field object.

This method will in addition set the AffectedRecords property with the number of records returned by this method.

If the ObjectState is Disconnected this method will return false.

Returns:
Type
System.Boolean
 

Public MethodUpdateOverloaded. Update

Runs an Update command with the fields marked with UseInSave as true. This method expects that all the primary key values have been specified.

If the Recursive property is set to anything other than None this Update will further call Update methods of the joined objects as well.

This method will reset the AffectedRecords property to the number of rows updated.

Business object must have at least one primary key field defined for this operation to work.

NOTE: As of version 3.x this method preserves each field's UseInSearch values, and does not reset any of the property values unlike the version 2.x and older did. Also starting version 3.x this method will retain any updated values for a later sync/save process if the ObjectState property is set to Disconnected. If the ObjectState property is set to Connected then the Update command is sent to the database immediatly.

Returns:
Type
System.Boolean
 

Public MethodUseAllFieldsForDisplayOverloaded. UseAllFieldsForDisplay

Resets all the field's Visible properties with the passed in value of use parameter. No joined objects are affected.

Parameters:
Description
use
 

Public MethodUseAllFieldsForSaveUseAllFieldsForSave

Resets all the field's UseInSave properties with the passed in value of use parameter. No joined objects are affected.

Parameters:
Description
use
 

Public MethodUseAllFieldsForSearchOverloaded. UseAllFieldsForSearch

Resets all the field's UseInSearch properties with the passed in value of use parameter. No joined objects are affected.

Parameters:
Description
use
 

Top

Protected Methods

 NameDescription
Protected MethodEnsureConnectionStringEnsureConnectionString

Checks the ConnectionString property and if it is nont set, it will try to get the Configuration / AppSettings / key (1.1 Framework) or Configuration / ConnectionStrings / key (2.0 Framework) that defines the database connection String.

Calling this method is not needed in normal scenarios. This will be needed only if you are changing the ConnectionStringConfigName property through the code and would want to ensure that the new value is loaded from the configuration file and the ConnectionString property is updated accordingly.

If you are calling EnsureDatabaseType method as well then you don't need to do that as EnsureDatabaseType is called by the EnsureConnectionString. (Inherited from Akal.QuickObjects.DBLibrary.DatabaseObject)

Protected MethodEnsureDatabaseTypeEnsureDatabaseType

Checks the DBType property and if it is set to None, it will try to get the Configuration / AppSettings / key that defines the DBType.

Calling this method is not needed in normal scenarios. This will be needed only if you are changing the DatabaseTypeConfigName property through the code and would want to ensure that the new value is loaded from the configuration file and the DBType property is updated accordingly.

If you are calling EnsureConnectionString method as well then you don't need to call EnsureDatabaseType as it is called by the EnsureConnectionString. (Inherited from Akal.QuickObjects.DBLibrary.DatabaseObject)

Protected MethodGetNewAdapterInstanceGetNewAdapterInstance

GetNewAdapterInstance creates a new instance of IDbDataAdapter compatible data adapter depending on the type of connection object stored in DBConnection property.

If the DBConnection property holds an OracleConnection then a OracleDataAdapter is created, however if the DBConnection property holds an SqlConnection then a SqlDataAdapter is created.

The passed in command object is passed to the data adapter. The command object must match the connection type i.e. If the DBConnection is set to SqlConnection then an instance of SqlCommand must be passed.

In normal scenarios there will not be a need to call this method, but it is provided for situations where a complex query has to be run which is not supported directly by this library.

Parameters:
Description
commandPass either a SqlCommand or OracleCommand based on the type of connection set in DBConnection.

Returns:
Type
IDbDataAdapter
(Inherited from Akal.QuickObjects.DBLibrary.DatabaseObjectSQL)

Protected MethodOnAfterDelete Invoked after the object has executed the Delete command.  
Protected MethodOnAfterFind Invoked after the object has executed the Find command.  
Protected MethodOnAfterInsert Invoked after the object has executed the Insert command.  
Protected MethodOnAfterLoad Invoked after the object has executed the Load command.  
Protected MethodOnAfterUpdate Invoked after the object has executed the Update command.  
Protected MethodOnBeforeDelete Invoked when the object is about to execute the Delete command.  
Protected MethodOnBeforeFind Invoked when the object is about to execute the Find command.  
Protected MethodOnBeforeInsert Invoked when the object is about to execute the Insert command.  
Protected MethodOnBeforeLoad Invoked when the object is about to execute the Load command.  
Protected MethodOnBeforeUpdate Invoked when the object is about to execute the Update command.  
Protected MethodOnObjectDisposing Invoked when the object is being disposed.  
Protected MethodOnObjectInitialized Invoked when the object is initialized.  
Top

Public Events

 NameDescription
Public EventAfterDelete Occurs after an object executes Delete command. The Success member of the event arguments can be used to determine if the command executed successfully.  
Public EventAfterFind Occurs after an object executes Find command. The Success member of the event arguments can be used to determine if the command executed successfully.  
Public EventAfterInsert Occurs after an object executes Insert command. The Success member of the event arguments can be used to determine if the command executed successfully.  
Public EventAfterLoad Occurs after an object executes Load command. The Success member of the event arguments can be used to determine if the command executed successfully.  
Public EventAfterUpdate Occurs after an object executes Update command. The Success member of the event arguments can be used to determine if the command executed successfully.  
Public EventBeforeDelete Occurs when an object is about to execute Delete command. This event can be used to cancel the command, by setting the Cancelled member of the event arguments.  
Public EventBeforeFind Occurs when an object is about to execute Find command. This event can be used to cancel the command, by setting the Cancelled member of the event arguments.  
Public EventBeforeInsert Occurs when an object is about to execute Insert command. This event can be used to cancel the command, by setting the Cancelled member of the event arguments.  
Public EventBeforeLoad Occurs when an object is about to execute Load command. This event can be used to cancel the command, by setting the Cancelled member of the event arguments.  
Public EventBeforeUpdate Occurs when an object is about to execute Update command. This event can be used to cancel the command, by setting the Cancelled member of the event arguments.  
Public EventObjectDisposing Occurs when an object instance is being disposed.  
Public EventObjectInitialized Occurs when an object instance is initialized.  
Top

See Also