QuickObjects.ObjectBase Send comments on this topic.
BulkUpdate Method
See Also  Example
Akal.QuickObjects.ObjectBase Namespace > BaseBusinessObject Class : BulkUpdate Method

BulkUpdate

You can specify search criteria on one or more objects, and also specify the fields that should be updated by the BulkUpdate. It is relatively very simple to update zero or more records without needing to write complex database specific sql statements.

The process involves setting each field's UseInSearch property to true that should be included in search, and setting UseInSave property to true for the fields that you would like to update.

Syntax

C# 
public virtual bool BulkUpdate()

Return Value

True if the BulkUpdate was successful. You can see the AffectedRecords property to find out how many records were updated.

Example

You can update multiple fields in multiple rows at the same time. You can limit the update to specific records by specifing a search criteria. The search critieria can be specified on the table being update or any of its related tables.
C#Copy Code
using (UserRoles ur = new UserRoles()) 

    ur.Join_RoleID_Roles_Parent(); 
    // We can specify search criteria on joined objects. 
    // In the following two lines we will assign the value "Client" to the RoleName and also set RoleName's UseInSearch property to true. 
    ur.RoleID_Roles_Parent.RoleName.Value = "Client"; 
    ur.RoleID_Roles_Parent.RoleName.UseInSearch = true; 
  
    // Our target is to set the IsActive to true (and 'Y' for Oracle) so we set the IsActive value to true, and set the IsActive's UseInSave property to true as well. 
    ur.IsActive.Value = true; 
    ur.IsActive.UseInSave = true; 
  
    // BulkUpdate method uses the search criteria and creates an update statement capable of updating 0-n records based on your criteria and available records in the database. 
    // If there is an error during the update process the method will return false. 
    if (ur.BulkUpdate()) 
    { 
        MessageBox.Show(ur.AffectedRecords.ToString() + " records updated"); 
    } 
    else 
    { 
        MessageBox.Show("Records could not be updated. Error: " + ur.ErrorString); 
    } 

    

Requirements

Target Platforms: .NET Framework 1.1 or .NET Framework 2.0

See Also