RecordsAffected Property

When executing a list method, the SmartObjectReader performs a SELECT operation twice - the first time to retrieve a count of the number of records, and the second time to retrieve the results. The RecordsAffected property has been added to the API to offer a performance increase by allowing the COUNT call to be omitted.  

Two classes have the RecordsAffected property:

  • SourceCode.SmartObjects.Client.SmartObjectReader
  • SourceCode.Data.SmartObjectsClient.SODataReader

Both of these classes inherit the property from their base class: System.Data.Common.DbDataReader.

Copy

DbDataReader.RecordsAffected Property

public sealed class ExecuteListReaderOptions : ExecuteListOptions, IReaderOptions
public bool OmitRecordsAffected { get; set; }
 
public sealed class ExecuteSQLQueryReaderOptions : ExecuteSQLQueryOptions, IReaderOptions
public bool OmitRecordsAffected { get; set; }

API methods to use the option classes

If you don't want to retrieve the COUNT for the list (so therefore not populate the RecordsAffected property), you must set the OmitRecordsAffected to true.

Copy

Execute methods

public class SmartObjectClientServer
public SmartObjectReader ExecuteListReader(JoinDetails joinDetails, ExecuteListReaderOptions options);
public SmartObjectReader ExecuteListReader(SmartObject smartObject, ExecuteListReaderOptions options);
public SmartObjectReader ExecuteSQLQueryReader(string sqlString, ExecuteSQLQueryReaderOptions options, DbParameter[] dbParameters);
Copy

Usage

// ExecuteListReader - JoinDetails
SmartObjectClientServer server; // Set SmartObjectClientServer
JoinDetails joinDetails; // Set JoinDetails
var options = new ExecuteListReaderOptions {
 OmitRecordsAffected = true
};

// ExecuteListReader – SmartObject
SmartObjectClientServer server; // Set SmartObjectClientServer
SmartObject smartObject; // Set SmartObject
var options = new ExecuteListReaderOptions {
 OmitRecordsAffected = true
};
server.ExecuteListReader(smartObject, options);

// ExecuteSQLQueryReader
SmartObjectClientServer server; // Set SmartObjectClientServer
List < SqlParameter > parameters; // Set DbParameter[]
string sqlQuery; // Set sqlQuery
var options = new ExecuteSQLQueryReaderOptions {
 OmitRecordsAffected = true
};
server.ExecuteSQLQueryReader(sqlQuery, options, parameters.ToArray());
Copy

Additional Option classes for changeability and refactoring

public abstract class ExecuteOptions
    {
        public int TransferRecords { get; set; }
    }

public class ExecuteListOptions : ExecuteOptions
    {
        public string ExecutionData { get; set; }
        public int PageNumber { get; set; }
        public int PageSize { get; set; }
    }


public class ExecuteSQLQueryOptions : ExecuteOptions
    {
        public bool AutoAlias { get; set; }
        public int MaxRecords { get; set; }
        public int StartRecord { get; set; }
    }

public interface IReaderOptions
    {
        bool OmitRecordsAffected { get; }
    }
    
Copy

Additional API methods

public class SmartObjectClientServer

public SmartObjectList ExecuteList(JoinDetails joinDetails, ExecuteListOptions options);
public SmartObjectList ExecuteList(SmartObject smartObject, ExecuteListOptions options);
public string ExecuteListCSV(JoinDetails joinDetails, ExecuteListOptions options);
public string ExecuteListCSV(SmartObject smartObject, ExecuteListOptions options);
public DataTable ExecuteListDataTable(JoinDetails joinDetails, ExecuteListOptions options);
public DataTable ExecuteListDataTable(SmartObject smartObject, ExecuteListOptions options);
public DataTable ExecuteSQLQueryDataTable(string sqlString, ExecuteSQLQueryOptions options, DbParameter[] dbParameters);