Class InMemoryProviderBase<RowType>
Inheritance
Implements
Inherited Members
Namespace: SuperOffice.CRM.ArchiveLists
Assembly: SoDataBase.dll
Syntax
public abstract class InMemoryProviderBase<RowType> : IArchiveProvider, IArchiveProviderHasRows, IArchiveProviderHasColumns, IArchiveProviderHasEntities where RowType : ArchiveRow, new()
Type Parameters
Name | Description |
---|---|
RowType |
Constructors
InMemoryProviderBase()
Declaration
protected InMemoryProviderBase()
Fields
AllowOrderBy
Symbolic boolean constant for ArchiveColumnInfo constructor, evaluates to 'true'
Declaration
protected const bool AllowOrderBy = true
Field Value
Type | Description |
---|---|
bool |
DenyOrderBy
Symbolic boolean constant for ArchiveColumnInfo constructor, evaluates to 'false'
Declaration
protected const bool DenyOrderBy = false
Field Value
Type | Description |
---|---|
bool |
Invisible
Symbolic boolean constant for ArchiveColumnInfo constructor, evaluates to 'false'
Declaration
protected const bool Invisible = false
Field Value
Type | Description |
---|---|
bool |
Options
Options from GetRows() call
Declaration
protected string Options
Field Value
Type | Description |
---|---|
string |
Visible
Symbolic boolean constant for ArchiveColumnInfo constructor, evaluates to 'true'
Declaration
protected const bool Visible = true
Field Value
Type | Description |
---|---|
bool |
_entityHelper
Declaration
protected EntityHelper _entityHelper
Field Value
Type | Description |
---|---|
EntityHelper |
Properties
BaseClassShouldFilterColumns
Subclass contract: Return true if the base class should filter columns according to SetDesiredColumns. If this property is false, the actual ArchiveRow objects are returned; otherwise a typed copy is made and ColumnData are populated accoprding to DesiredColumns.
Declaration
protected abstract bool BaseClassShouldFilterColumns { get; }
Property Value
Type | Description |
---|---|
bool |
Remarks
If columns are cheap to get, the subclass can save code by leaving the filtering to this base class. Conversely, if somecolumns are expensive to calculate, the subclass should do the filtering itself to improve performance.
BaseClassShouldFilterEntities
Subclass contract: Return true if the base class should filter columns according to SetDesiredColumns. If this property is false, the actual ArchiveRow objects are returned; otherwise a typed copy is made and ColumnData are populated accoprding to DesiredColumns.
Declaration
protected abstract bool BaseClassShouldFilterEntities { get; }
Property Value
Type | Description |
---|---|
bool |
Remarks
If columns are cheap to get, the subclass can save code by leaving the filtering to this base class. Conversely, if somecolumns are expensive to calculate, the subclass should do the filtering itself to improve performance.
BaseClassShouldPage
Subclass contract: Return true if the base class should perform filter entities according to SetDesiredEntities. If this property is false, the result set is assumed to represent the chosen entities only.
Declaration
protected abstract bool BaseClassShouldPage { get; }
Property Value
Type | Description |
---|---|
bool |
Remarks
If rows are cheap to get, the subclass can save code by leaving the filtering to this base class. Conversely, if rows are expensive to calculate, the subclass should do the entity filtering itself to improve performance.
BaseClassShouldSort
Subclass contract: Return true if the base class should perform sorting according to SetOrderBy. If this property is false, the result set is assumed to be correctly ordered.
Declaration
protected abstract bool BaseClassShouldSort { get; }
Property Value
Type | Description |
---|---|
bool |
ColumnHelper
Declaration
protected ColumnHelper ColumnHelper { get; }
Property Value
Type | Description |
---|---|
ColumnHelper |
EntityHelper
Declaration
protected EntityHelper EntityHelper { get; }
Property Value
Type | Description |
---|---|
EntityHelper |
Methods
Close()
Call this method after the last desired row has been read; this gives the provider the chance to close and free any underlying queries
Declaration
public virtual void Close()
GetAvailableColumns()
Get the list of columns handled by this provider
Declaration
public virtual List<ArchiveColumnInfo> GetAvailableColumns()
Returns
Type | Description |
---|---|
List<ArchiveColumnInfo> |
GetAvailableEntities()
Get the list of entities supported by this provider
Declaration
public virtual List<ArchiveRowTypeInfo> GetAvailableEntities()
Returns
Type | Description |
---|---|
List<ArchiveRowTypeInfo> |
GetReader(string)
Start the reader and return an IDataReader (which, as we remember, also inherits IDataRecord for access to individual data fields). This provides an alternative, more generic and more standards-based interface to data. Use either GetRows or GetReader on any particular archive provider instance.
Declaration
public virtual IDataReader GetReader(string options)
Parameters
Type | Name | Description |
---|---|---|
string | options |
Returns
Type | Description |
---|---|
IDataReader |
GetResultData()
Subclass contract: Return a list of ArchiveRow items that are the current result
Declaration
protected abstract List<RowType> GetResultData()
Returns
Type | Description |
---|---|
List<RowType> | result list, which may be paged, sorted and column-filtered, or not, according to the abstract properties |
GetResultInformation()
Get additional information about the result, such as row count or other optional items. This method should be called some time after GetRows, but before Close. Delaying calls to this method as long as possible will give its (asynchronous) internal counterpart more time to complete and lessen the response-time impact of calling it.
Declaration
public virtual ArchiveResultInformation GetResultInformation()
Returns
Type | Description |
---|---|
ArchiveResultInformation |
GetRows(string)
Start the query and return an iterator. The .Current property will be a valid ArchiveRow containing one row, as long as a previous call to .MoveNext returned true. This is the standard semantics for an iterator. Do remember to call Close afterwards, to clean up all resources.
Declaration
public virtual IEnumerable<ArchiveRow> GetRows(string options)
Parameters
Type | Name | Description | ||||
---|---|---|---|---|---|---|
string | options | A set of options, using the query string format (name=value&...). Can be null or empty.
|
Returns
Type | Description |
---|---|
IEnumerable<ArchiveRow> | An iterator, following the usual conventions. MoveNext will return false when there are no more rows, which can either be because the result set is exhausted, or because the page size has been reached |
Remarks
You can use the foreach keyword to iterate over rows, like this:
IArchiveProvider provider = ArchiveProviderFactory.Create("person");
// not shown - set desired columns, entities, restrictions, paging
foreach( ArchiveRow row in provider.GetRows() )
{
// process row here
}
provider.Close();
RegisterEntity(ArchiveRowTypeInfo)
Register an entity on this provider
Declaration
protected ArchiveRowTypeInfo RegisterEntity(ArchiveRowTypeInfo entity)
Parameters
Type | Name | Description |
---|---|---|
ArchiveRowTypeInfo | entity | Entity to register |
Returns
Type | Description |
---|---|
ArchiveRowTypeInfo | The same entity, so you can go on doing things to it |
SetDesiredColumns(params string[])
Set which columns should actually be returned, must be a subset of the GetAvailableColumns result
Declaration
public virtual void SetDesiredColumns(params string[] columnIds)
Parameters
Type | Name | Description |
---|---|---|
string[] | columnIds | Array of column ID's representing the desired columns |
SetDesiredEntities(params string[])
Declaration
public virtual void SetDesiredEntities(params string[] entities)
Parameters
Type | Name | Description |
---|---|---|
string[] | entities | Array of entity names, semantically equivalent to ArchiveEntityInfo.Name fields. |
SetOrderBy(params ArchiveOrderByInfo[])
Declaration
public virtual void SetOrderBy(params ArchiveOrderByInfo[] orderBy)
Parameters
Type | Name | Description |
---|---|---|
ArchiveOrderByInfo[] | orderBy | Array of order by items |
SetPagingInfo(int, int)
Set the paging properties of the provider. The default is to fetch page zero, of one thousand (1000) rows. A more reasonable page size is probably around 100. Note that the query processing strategy may change for very large pages (more than 1000) and give significantly longer response times. Performance is improved by setting the page size low, as long as you don't set it lower than what you realistically expect to need (fetching multiple pages is more expensive than fetching one).
Declaration
public virtual void SetPagingInfo(int pageSize, int pageNumber)
Parameters
Type | Name | Description |
---|---|---|
int | pageSize | Desired page size |
int | pageNumber | Desired page number to return |
SetRestriction(params ArchiveRestrictionInfo[])
Set query restriction globally, supersedes previous restrictions
Declaration
public virtual bool SetRestriction(params ArchiveRestrictionInfo[] restrictions)
Parameters
Type | Name | Description |
---|---|---|
ArchiveRestrictionInfo[] | restrictions | Array of restrictions, with an implicit AND between them |
Returns
Type | Description |
---|---|
bool | true if at least one of the restrictions matched one of the available columns of the provider |
SortData(List<RowType>)
Sort the given list of archive rows according to the current orderby criteria
Declaration
protected void SortData(List<RowType> dataToSort)
Parameters
Type | Name | Description |
---|---|---|
List<RowType> | dataToSort |