Show / Hide Table of Contents

Class RowsetBase

Provides base for rowset implementation. Rowsets are mutable lists of rows where all rows must have the same schema, however a rowset may contain a mix of dynamic and typed rows as long as they have the same schema. Rowsets are not thread-safe

Inheritance
System.Object
RowsetBase
Rowset
Table
Implements
System.Collections.Generic.IList<Row>
System.Collections.Generic.ICollection<Row>
System.Collections.Generic.IEnumerable<Row>
System.Collections.IEnumerable
System.Collections.Generic.IComparer<Row>
IJSONWritable
IValidatable
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: NFX.DataAccess.CRUD
Assembly: NFX.dll
Syntax
[Serializable]
public abstract class RowsetBase : IList<Row>, ICollection<Row>, IEnumerable<Row>, IEnumerable, IComparer<Row>, IJSONWritable, IValidatable

Constructors

RowsetBase(Schema)

Creates an empty rowset

Declaration
protected RowsetBase(Schema schema)
Parameters
Type Name Description
Schema schema

Fields

m_Changes

Declaration
protected List<RowChange> m_Changes
Field Value
Type Description
System.Collections.Generic.List<RowChange>

m_List

Declaration
protected List<Row> m_List
Field Value
Type Description
System.Collections.Generic.List<Row>

m_Schema

Declaration
protected Schema m_Schema
Field Value
Type Description
Schema

Properties

AsReadonlyIList

Returns data as non-generic readonly IList

Declaration
public IList AsReadonlyIList { get; }
Property Value
Type Description
System.Collections.IList

ChangeCount

Returns a count of accumulated modifications performed on the rowset, or zero when no modifications have been made or LogModifications = false

Declaration
public int ChangeCount { get; }
Property Value
Type Description
System.Int32

Changes

Returns accumulated modifications performed on the rowset, or empty enumerator if no modifications have been made or LogModifications = false

Declaration
public IEnumerable<RowChange> Changes { get; }
Property Value
Type Description
System.Collections.Generic.IEnumerable<RowChange>

Context

Provides dynamic view of rowset's data context - attributes applicable to the whole rowset

Declaration
public dynamic Context { get; }
Property Value
Type Description
System.Object

ContextMap

Provides dynamic view as JSONDataMap of rowset's data context - attributes applicable to the whole rowset

Declaration
public JSONDataMap ContextMap { get; }
Property Value
Type Description
JSONDataMap

Count

Returns row count in this rowset

Declaration
public int Count { get; }
Property Value
Type Description
System.Int32

InstanceGUID

Returns globaly-unique instance ID. This ID is useful as a key for storing rowsets in object stores and posting data back from web client to server.

Declaration
public Guid InstanceGUID { get; }
Property Value
Type Description
System.Guid

IsReadOnly

Declaration
public bool IsReadOnly { get; }
Property Value
Type Description
System.Boolean

Item[Int32]

This method performs update on set

Declaration
public virtual Row this[int index] { get; set; }
Parameters
Type Name Description
System.Int32 index
Property Value
Type Description
Row

LogChanges

Gets/Sets whether this rowset keeps track of all modifications done to it. This property must be set to true to be able to save changes into ICRUDDataStore

Declaration
public bool LogChanges { get; set; }
Property Value
Type Description
System.Boolean

Schema

Returns a schema for rows that this rowset contains

Declaration
public Schema Schema { get; }
Property Value
Type Description
Schema

Methods

Add(Row)

Inserts a row

Declaration
public void Add(Row row)
Parameters
Type Name Description
Row row

Check(Row)

Checks argument for being non-null and of the same schema with this rowset

Declaration
protected void Check(Row row)
Parameters
Type Name Description
Row row

Clear()

Purges table

Declaration
public void Clear()

Compare(Row, Row)

Compares two rows

Declaration
public abstract int Compare(Row rowA, Row rowB)
Parameters
Type Name Description
Row rowA
Row rowB
Returns
Type Description
System.Int32

Contains(Row)

Declaration
public bool Contains(Row row)
Parameters
Type Name Description
Row row
Returns
Type Description
System.Boolean

CopyTo(Row[], Int32)

Declaration
public void CopyTo(Row[] array, int arrayIndex)
Parameters
Type Name Description
Row[] array
System.Int32 arrayIndex

Delete(Row, IDataStoreKey)

Tries to find a row with the same set of key fields in this table and if found, deletes it and returns its index, otherwise -1

Declaration
public int Delete(Row row, IDataStoreKey key = null)
Parameters
Type Name Description
Row row
IDataStoreKey key
Returns
Type Description
System.Int32

Delete(Object[])

Tries to find a row with the same set of key fields in this table and if found, deletes it and returns its index, otherwise -1

Declaration
public int Delete(params object[] keys)
Parameters
Type Name Description
System.Object[] keys
Returns
Type Description
System.Int32

DeleteAll()

Deletes all rows from table. This method is similar to Purge() but does logging (when enabled)

Declaration
public void DeleteAll()

DoDelete(Row, IDataStoreKey)

Tries to find a row with the same set of key fields in this table and if found, deletes it and returns its index, otherwise -1

Declaration
protected virtual int DoDelete(Row row, IDataStoreKey key = null)
Parameters
Type Name Description
Row row
IDataStoreKey key
Returns
Type Description
System.Int32

DoInsert(Row)

Tries to insert a row. If another row with the same set of key fields already in the table returns -1, otherwise returns insertion index

Declaration
protected virtual int DoInsert(Row row)
Parameters
Type Name Description
Row row
Returns
Type Description
System.Int32

DoKeyRowFromValues<T>(T, Object[])

Declaration
protected T DoKeyRowFromValues<T>(T krow, params object[] keys)where T : Row
Parameters
Type Name Description
T krow
System.Object[] keys
Returns
Type Description
T
Type Parameters
Name Description
T

DoUpdate(Row, IDataStoreKey, Func<Row, Row, Row>)

Tries to find a row with the same set of key fields in this table and if found, replaces it and returns its index, otherwise returns -1

Declaration
protected virtual int DoUpdate(Row row, IDataStoreKey key = null, Func<Row, Row, Row> rowUpgrade = null)
Parameters
Type Name Description
Row row

Row

IDataStoreKey key

Primary key

System.Func<Row, Row, Row> rowUpgrade

When not null, is called with old and new instance of the row to be updated. It returns the row to be saved. Note that the returned row must have the same key and schema or else the function will throw.

Returns
Type Description
System.Int32

DoUpgrade(Int32, Row, Func<Row, Row, Row>)

Apply rowUpgrade function to the row stored at index "idx" and the new "row" passed as second argument, and store the returned row back at index "idx".

Declaration
protected virtual void DoUpgrade(int idx, Row newRow, Func<Row, Row, Row> rowUpgrade)
Parameters
Type Name Description
System.Int32 idx
Row newRow
System.Func<Row, Row, Row> rowUpgrade

DoUpsert(Row, Func<Row, Boolean>, Func<Row, Row, Row>)

Tries to find a row with the same set of key fields in this table and if found, replaces it and returns true, otherwise inserts the row (if schemas match) and returns false. Optionally pass updateWhere condition that may check whether update needs to be performed

Declaration
protected virtual UpdateResult DoUpsert(Row row, Func<Row, bool> updateWhere, Func<Row, Row, Row> rowUpgrade = null)
Parameters
Type Name Description
Row row
System.Func<Row, System.Boolean> updateWhere
System.Func<Row, Row, Row> rowUpgrade
Returns
Type Description
UpdateResult

FindByKey(Row)

Tries to find a row by specified keyset and returns it or null if not found

Declaration
public Row FindByKey(Row keyRow)
Parameters
Type Name Description
Row keyRow
Returns
Type Description
Row

FindByKey(Row, Func<Row, Boolean>)

Tries to find a row by specified keyset and extra WHERE clause and returns it or null if not found. This method does not perform well on Rowsets instances as a rowset is unordered list which does linear search. In contrast, Tables are always ordered and perform binary search instead

Declaration
public Row FindByKey(Row row, Func<Row, bool> extraWhere)
Parameters
Type Name Description
Row row
System.Func<Row, System.Boolean> extraWhere
Returns
Type Description
Row

FindByKey(Func<Row, Boolean>, Object[])

Tries to find a row index by specified keyset and extra WHERE clause and returns it or null if not found

Declaration
public Row FindByKey(Func<Row, bool> extraWhere, params object[] keys)
Parameters
Type Name Description
System.Func<Row, System.Boolean> extraWhere
System.Object[] keys
Returns
Type Description
Row

FindByKey(Object[])

Tries to find a row by specified keyset and returns it or null if not found. This method does not perform well on Rowsets instances as a rowset is unordered list which does linear search. In contrast, Tables are always ordered and perform binary search instead

Declaration
public Row FindByKey(params object[] keys)
Parameters
Type Name Description
System.Object[] keys
Returns
Type Description
Row

FindIndexByKey(Row)

Tries to find a row index by specified keyset and returns it or null if not found

Declaration
public int FindIndexByKey(Row keyRow)
Parameters
Type Name Description
Row keyRow
Returns
Type Description
System.Int32

FindIndexByKey(Row, Func<Row, Boolean>)

Tries to find a row index by specified keyset and extra WHERE clause and returns it or null if not found. This method does not perform well on Rowsets instances as a rowset is unordered list which does linear search. In contrast, Tables are always ordered and perform binary search instead

Declaration
public int FindIndexByKey(Row row, Func<Row, bool> extraWhere)
Parameters
Type Name Description
Row row
System.Func<Row, System.Boolean> extraWhere
Returns
Type Description
System.Int32

FindIndexByKey(Func<Row, Boolean>, Object[])

Tries to find a row index by specified keyset and extra WHERE clause and returns it or null if not found

Declaration
public int FindIndexByKey(Func<Row, bool> extraWhere, params object[] keys)
Parameters
Type Name Description
System.Func<Row, System.Boolean> extraWhere
System.Object[] keys
Returns
Type Description
System.Int32

FindIndexByKey(Object[])

Tries to find a row index by specified keyset and returns it or null if not found. This method does not perform well on Rowsets instances as a rowset is unordered list which does linear search. In contrast, Tables are always ordered and perform binary search instead

Declaration
public int FindIndexByKey(params object[] keys)
Parameters
Type Name Description
System.Object[] keys
Returns
Type Description
System.Int32

FromJSON(JSONDataMap, Boolean, Boolean)

Reads either Table or Rowset from JSON created by WriteAsJSON. Metadata must be present

Declaration
public static RowsetBase FromJSON(JSONDataMap jsonMap, bool schemaOnly = false, bool readOnlySchema = false)
Parameters
Type Name Description
JSONDataMap jsonMap
System.Boolean schemaOnly
System.Boolean readOnlySchema
Returns
Type Description
RowsetBase

FromJSON(JSONDataMap, out Boolean, Boolean, Boolean, SetFieldFunc)

Reads either Table or Rowset from JSON created by WriteAsJSON. Metadata must be present. allMatched==false when some data did not match schema (i.e. too little fields or extra fields supplied)

Declaration
public static RowsetBase FromJSON(JSONDataMap jsonMap, out bool allMatched, bool schemaOnly = false, bool readOnlySchema = false, SetFieldFunc setFieldFunc = null)
Parameters
Type Name Description
JSONDataMap jsonMap
System.Boolean allMatched
System.Boolean schemaOnly
System.Boolean readOnlySchema
SetFieldFunc setFieldFunc
Returns
Type Description
RowsetBase

FromJSON(String, Boolean, Boolean)

Reads either Table or Rowset from JSON created by WriteAsJSON. Metadata must be present

Declaration
public static RowsetBase FromJSON(string json, bool schemaOnly = false, bool readOnlySchema = false)
Parameters
Type Name Description
System.String json
System.Boolean schemaOnly
System.Boolean readOnlySchema
Returns
Type Description
RowsetBase

FromJSON<T>(JSONDataMap, ref RowsetBase, SetFieldFunc)

Reads either Table or Rowset from JSON created by WriteAsJSON.

Declaration
public static int FromJSON<T>(JSONDataMap jsonMap, ref RowsetBase result, SetFieldFunc setFieldFunc = null)where T : TypedRow, new ()
Parameters
Type Name Description
JSONDataMap jsonMap
RowsetBase result
SetFieldFunc setFieldFunc
Returns
Type Description
System.Int32

Total number of rows found in JSON. If this number is less than result.Count, then not all rows matched the schema of the resulting rowset.

Type Parameters
Name Description
T
Remarks

The schema of "result" must match the schema of the typed row T. It's the responsibility of the caller to clear the "result" prior to calling this function - the function appends rows to existing rowset.

FromJSON<T>(String, ref RowsetBase, SetFieldFunc)

Reads either Table or Rowset from JSON created by WriteAsJSON.

Declaration
public static int FromJSON<T>(string json, ref RowsetBase result, SetFieldFunc setFieldFunc = null)where T : TypedRow, new ()
Parameters
Type Name Description
System.String json
RowsetBase result
SetFieldFunc setFieldFunc
Returns
Type Description
System.Int32

Total number of rows found in JSON. If this number is less than result.Count, then not all rows matched the schema of the resulting rowset.

Type Parameters
Name Description
T
Remarks

The schema of "result" must match the schema of the typed row T. It's the responsibility of the caller to clear the "result" prior to calling this function - the function appends rows to existing rowset.

GetChangeAt(Int32)

Retrievs a change by index or null if index is out of bounds or changes are not logged

Declaration
public RowChange? GetChangeAt(int idx)
Parameters
Type Name Description
System.Int32 idx
Returns
Type Description
System.Nullable<RowChange>

GetEnumerator()

Declaration
public IEnumerator<Row> GetEnumerator()
Returns
Type Description
System.Collections.Generic.IEnumerator<Row>

IndexOf(Row)

Declaration
public int IndexOf(Row row)
Parameters
Type Name Description
Row row
Returns
Type Description
System.Int32

Insert(Row)

Inserts the row. Returns insertion index

Declaration
public int Insert(Row row)
Parameters
Type Name Description
Row row
Returns
Type Description
System.Int32

Insert(Int32, Row)

Inserts row at index

Declaration
public virtual void Insert(int index, Row row)
Parameters
Type Name Description
System.Int32 index
Row row

KeyRowFromValues(Object[])

Creates key row out of field values for keys

Declaration
public Row KeyRowFromValues(params object[] keys)
Parameters
Type Name Description
System.Object[] keys
Returns
Type Description
Row

Purge()

Deletes all rows from table without logging the deleted modifications even when LogModifications=true

Declaration
public void Purge()

PurgeChanges()

Clears modifications accumulated by this instance

Declaration
public void PurgeChanges()

Remove(Row)

Performs row delete

Declaration
public bool Remove(Row item)
Parameters
Type Name Description
Row item
Returns
Type Description
System.Boolean

RemoveAt(Int32)

Deletes row

Declaration
public void RemoveAt(int index)
Parameters
Type Name Description
System.Int32 index

SearchForRow(Row, out Int32)

Provides rowsearching. Override to do binary search in sorted rowsets

Declaration
protected virtual int SearchForRow(Row row, out int index)
Parameters
Type Name Description
Row row

A row to search for

System.Int32 index

An index where search collapsed without finding the match. Used for sorted insertions

Returns
Type Description
System.Int32

Update(Row, IDataStoreKey, Func<Row, Row, Row>)

Updates the row, Returns the row index or -1

Declaration
public UpdateResult Update(Row row, IDataStoreKey key = null, Func<Row, Row, Row> rowUpgrade = null)
Parameters
Type Name Description
Row row
IDataStoreKey key
System.Func<Row, Row, Row> rowUpgrade
Returns
Type Description
UpdateResult

Upsert(Row, Func<Row, Boolean>, Func<Row, Row, Row>)

Tries to find a row for update and if found, updates it and returns true, otherwise inserts the row (if schemas match) and returns false. Optionally pass updateWhere condition that may check whether update needs to be performed

Declaration
public UpdateResult Upsert(Row row, Func<Row, bool> updateWhere = null, Func<Row, Row, Row> rowUpgrade = null)
Parameters
Type Name Description
Row row
System.Func<Row, System.Boolean> updateWhere
System.Func<Row, Row, Row> rowUpgrade
Returns
Type Description
UpdateResult

Validate(String)

Validates all rows in this rowset. Override to perform custom validations. The method is not expected to throw exception in case of failed validation, rather return exception instance because throwing exception really hampers validation performance when many rows need to be validated

Declaration
public virtual Exception Validate(string targetName)
Parameters
Type Name Description
System.String targetName
Returns
Type Description
System.Exception

WriteAsJSON(TextWriter, Int32, JSONWritingOptions)

Writes rowset as JSON including schema information. Do not call this method directly, instead call rowset.ToJSON() or use JSONWriter class

Declaration
public void WriteAsJSON(TextWriter wri, int nestingLevel, JSONWritingOptions options = null)
Parameters
Type Name Description
System.IO.TextWriter wri
System.Int32 nestingLevel
JSONWritingOptions options

Explicit Interface Implementations

IEnumerable.GetEnumerator()

Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type Description
System.Collections.IEnumerator

Implements

System.Collections.Generic.IList<T>
System.Collections.Generic.ICollection<T>
System.Collections.Generic.IEnumerable<T>
System.Collections.IEnumerable
System.Collections.Generic.IComparer<T>
IJSONWritable
IValidatable

Extension Methods

CollectionUtils.ForEach<T>(IEnumerable<T>, Action<T>)
CollectionUtils.ForEach<T>(IEnumerable<T>, Action<T, Int32>)
CollectionUtils.SkipLast<T>(IEnumerable<T>)
CollectionUtils.SkipLast<T>(IEnumerable<T>, Int32)
CollectionUtils.FirstMin<TResult, TComparand>(IEnumerable<TResult>, Func<TResult, TComparand>)
CollectionUtils.FirstMin<TResult, TComparand>(IEnumerable<TResult>, Func<TResult, TComparand>, out TComparand)
CollectionUtils.FirstMax<TResult, TComparand>(IEnumerable<TResult>, Func<TResult, TComparand>)
CollectionUtils.FirstMax<TResult, TComparand>(IEnumerable<TResult>, Func<TResult, TComparand>, out TComparand)
CollectionUtils.FirstOrAnyOrDefault<TResult>(IEnumerable<TResult>, Func<TResult, Boolean>)
CollectionUtils.Distinct<TResult, TKey>(IEnumerable<TResult>, Func<TResult, TKey>)
DataUtils.AsEnumerableOf<TRow>(IEnumerable<Row>)
MiscUtils.NonNull<T>(T, Func<Exception>, String)
ObjectValueConversion.AsString(Object, String, ConvertErrorHandling)
ObjectValueConversion.AsNonNullOrEmptyString(Object)
ObjectValueConversion.AsLaconicConfig(Object, ConfigSectionNode, String, ConvertErrorHandling)
ObjectValueConversion.AsJSONConfig(Object, ConfigSectionNode, String, ConvertErrorHandling)
ObjectValueConversion.AsXMLConfig(Object, ConfigSectionNode, ConvertErrorHandling)
ObjectValueConversion.AsChar(Object, Char, ConvertErrorHandling)
ObjectValueConversion.AsNullableChar(Object, Nullable<Char>, ConvertErrorHandling)
ObjectValueConversion.AsByte(Object, Byte, ConvertErrorHandling)
ObjectValueConversion.AsNullableByte(Object, Nullable<Byte>, ConvertErrorHandling)
ObjectValueConversion.AsSByte(Object, SByte, ConvertErrorHandling)
ObjectValueConversion.AsNullableSByte(Object, Nullable<SByte>, ConvertErrorHandling)
ObjectValueConversion.AsShort(Object, Int16, ConvertErrorHandling)
ObjectValueConversion.AsNullableShort(Object, Nullable<Int16>, ConvertErrorHandling)
ObjectValueConversion.AsUShort(Object, UInt16, ConvertErrorHandling)
ObjectValueConversion.AsNullableUShort(Object, Nullable<UInt16>, ConvertErrorHandling)
ObjectValueConversion.AsInt(Object, Int32, ConvertErrorHandling)
ObjectValueConversion.AsNullableInt(Object, Nullable<Int32>, ConvertErrorHandling)
ObjectValueConversion.AsUInt(Object, UInt32, ConvertErrorHandling)
ObjectValueConversion.AsNullableUInt(Object, Nullable<UInt32>, ConvertErrorHandling)
ObjectValueConversion.AsLong(Object, Int64, ConvertErrorHandling)
ObjectValueConversion.AsNullableLong(Object, Nullable<Int64>, ConvertErrorHandling)
ObjectValueConversion.AsULong(Object, UInt64, ConvertErrorHandling)
ObjectValueConversion.AsNullableULong(Object, Nullable<UInt64>, ConvertErrorHandling)
ObjectValueConversion.AsDouble(Object, Double, ConvertErrorHandling)
ObjectValueConversion.AsNullableDouble(Object, Nullable<Double>, ConvertErrorHandling)
ObjectValueConversion.AsFloat(Object, Single, ConvertErrorHandling)
ObjectValueConversion.AsNullableFloat(Object, Nullable<Single>, ConvertErrorHandling)
ObjectValueConversion.AsDecimal(Object, Decimal, ConvertErrorHandling)
ObjectValueConversion.AsNullableDecimal(Object, Nullable<Decimal>, ConvertErrorHandling)
ObjectValueConversion.AsBool(Object, Boolean, ConvertErrorHandling)
ObjectValueConversion.AsNullableBool(Object, Nullable<Boolean>, ConvertErrorHandling)
ObjectValueConversion.AsGUID(Object, Guid, ConvertErrorHandling)
ObjectValueConversion.AsNullableGUID(Object, Nullable<Guid>, ConvertErrorHandling)
ObjectValueConversion.AsDateTime(Object)
ObjectValueConversion.AsDateTime(Object, DateTime, ConvertErrorHandling)
ObjectValueConversion.AsNullableDateTime(Object, Nullable<DateTime>, ConvertErrorHandling)
ObjectValueConversion.AsGDID(Object)
ObjectValueConversion.AsGDID(Object, GDID, ConvertErrorHandling)
ObjectValueConversion.AsNullableGDID(Object, Nullable<GDID>, ConvertErrorHandling)
ObjectValueConversion.AsGDIDSymbol(Object)
ObjectValueConversion.AsGDIDSymbol(Object, GDIDSymbol, ConvertErrorHandling)
ObjectValueConversion.AsNullableGDIDSymbol(Object, Nullable<GDIDSymbol>, ConvertErrorHandling)
ObjectValueConversion.AsTimeSpan(Object)
ObjectValueConversion.AsTimeSpan(Object, TimeSpan, ConvertErrorHandling)
ObjectValueConversion.AsNullableTimeSpan(Object, Nullable<TimeSpan>, ConvertErrorHandling)
ObjectValueConversion.AsEnum<TEnum>(Object, TEnum, ConvertErrorHandling)
ObjectValueConversion.AsNullableEnum<TEnum>(Object, Nullable<TEnum>, ConvertErrorHandling)
ObjectValueConversion.AsUri(Object, Uri, ConvertErrorHandling)
LookAheadExtensions.AsLookAheadEnumerable<T>(IEnumerable<T>)
JSONExtensions.ToJSON(Object, JSONWritingOptions)
JSONExtensions.ToJSON(Object, TextWriter, JSONWritingOptions)
JSONExtensions.ToJSON(Object, Stream, JSONWritingOptions, Encoding)
ErlObject.ToErlObject(Object)
ErlObject.ToErlObject(Object, ErlTypeOrder, Boolean)
Back to top Copyright © 2006-2018 Agnicore Inc
Generated by DocFX