Table of Contents

Class DataContext

Namespace
TimeCockpit.Data
Assembly
TimeCockpit.Data.dll

Represents the class that manages access to meta data.

public sealed class DataContext : DynamicObject, IDynamicMetaObjectProvider, IDataContext, IDisposable
Inheritance
Object
DataContext
Implements
IDynamicMetaObjectProvider
IDisposable
Inherited Members
Object.ToString()
Object.Equals(Object)
Object.Equals(Object, Object)
Object.ReferenceEquals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Extension Methods

Remarks

The DataContext provides functionality to query or manipulate an underlying datastore. This applies to both, the data and meta model. That is, users can insert, update or delete data or can change the structure of the data via the belonging Model.

Properties

DataContextType

Gets the DataContextType of the current instance of DataContext.

public DataContextType DataContextType { get; }

Property Value

DataContextType

Remarks

The type of the data context may either be DataContextType.Client or DataContextType.Server. When a DataContext is instantiated with DataContext.Client no writable Model can be requested from the Model. That is, no changes to the meta data of a DataContext can be made. In contrast to that, a DataContext that has been instantiated with DataContext.Server can request a writable Model. See also TimeCockpit.Data.DataContext.GetWritableModel(System.Boolean)

DbClient

Gets the reference to the underlying DbClient object.

public DbClient DbClient { get; }

Property Value

DbClient

Remarks

The DbClient it the executing unit that performs all data access via the current instance of the DataContext

Exceptions

System.ArgumentNullException

Thrown if it is tried to set the property to null.

Environment

Gets the environment for the current instance of DataContext.

public Environment Environment { get; }

Property Value

Environment

Localizer

Gets the localization implementation that is used.

public NameLocalizer Localizer { get; }

Property Value

NameLocalizer

Model

Gets the Model associated with this context.

public Model Model { get; }

Property Value

Model

Remarks

The Model of an instance of a DataContext represents the meta data storage of the current DataContext. It describes how the data that can be accessed with the current instance looks like.

Methods

Create(String, String)

Creates a new instance of the DataContext class based on the specified DataContextSettings and on the connection information fetched from the management service.

public static DataContext Create(string userName, string password)

Parameters

userName String

The username to access the management webservice.

password String

The password to access the management webservice.

Returns

DataContext

New instance of the DataContext class.

Remarks

This method fetches an instance of WebManagementService.ConnectionInformation from the management service to determine where to connect to. Thus it can only create a data context to a remote sql azure database, that is, an instance of a DataContext with type Server.

Exceptions

System.ArgumentException

Create(String, String, String)

Creates a new instance of the DataContext class based on the specified DataContextSettings and on the connection information fetched from the management service.

public static DataContext Create(string userName, string password, string endpointName)

Parameters

userName String

The username to access the management webservice.

password String

The password to access the management webservice.

endpointName String

The name of the service endpoint where to access the management service.

Returns

DataContext

New instance of the DataContext class.

Remarks

This method fetches an instance of WebManagementService.ConnectionInformation from the management service to determine where to connect to. Thus it can only create a data context to a remote sql azure database, that is, an instance of a DataContext with type Server.

Exceptions

System.ArgumentException

Create(String, String, String, String)

Creates a new instance of the DataContext class based on the specified DataContextSettings and on the connection information fetched from the management service.

public static DataContext Create(string userName, string password, string endpointName, string endpointAddress)

Parameters

userName String

The username to access the management webservice.

password String

The password to access the management webservice.

endpointName String

The name of the service endpoint where to access the management service.

endpointAddress String

The address of the endpoint.

Returns

DataContext

New instance of the DataContext class.

Remarks

This method fetches an instance of WebManagementService.ConnectionInformation from the management service to determine where to connect to. Thus it can only create a data context to a remote sql azure database, that is, an instance of a DataContext with type Server.

Exceptions

System.ArgumentException

Create(String, String, String, DataContextSettings, String)

Creates a new instance of the DataContext class based on the specified DataContextSettings and on the connection information fetched from the management service.

public static DataContext Create(string userName, string password, string endpointName, DataContextSettings settings, string endpointAddress = null)

Parameters

userName String

The username to access the management webservice.

password String

The password to access the management webservice.

endpointName String

The name of the service endpoint where to access the management service.

settings DataContextSettings

Settings that define the behavior of the created DataContext instance.

endpointAddress String

The address of the endpoint.

Returns

DataContext

New instance of the DataContext class.

Remarks

This method fetches an instance of WebManagementService.ConnectionInformation from the management service to determine where to connect to. Thus it can only create a data context to a remote sql azure database, that is, an instance of a DataContext with type Server.

ATTENTION: If either a provider name, connection string, a blob storage account name, a shared access key or a tenant schema was set in the settings.DbClientSettings parameter, the latter settings will overwritten with the data fetched from the management service. Further it creates a DataContext of type Server that is, changes are allowed.

Exceptions

System.ArgumentException

Create(DataContextSettings)

Creates a new instance of the DataContext class based on the specified DataContextSettings.

public static DataContext Create(DataContextSettings settings)

Parameters

settings DataContextSettings

Settings that define the behavior of the created DataContext instance.

Returns

DataContext

New instance of the DataContext class.

Remarks

This method to create a new instance of DataContext can be used to create either DataContexts of type Server or Client (local connection to Sql CE).

This factory methods creates the DbClient to access the database and, if InstallMissingSystemObjects it true, install missing system object (or adds missing ones).

Further, if InstallMissingSystemEntities is true, missing system entities are installed.

Exceptions

System.ArgumentException

DeleteObject(EntityObject)

Deletes a given EntityObject.

public void DeleteObject(EntityObject entityObject)

Parameters

entityObject EntityObject

The EntityObject to delete.

Remarks

This method marks the instance EntityObject as deleted and subsequently calls SaveObject(EntityObject) for the object.

DeleteObjectAsync(EntityObject)

Deletes a given EntityObject.

[Obsolete("Avoid until task based implementation becomes available.")]
public IObservable<Unit> DeleteObjectAsync(EntityObject entityObject)

Parameters

entityObject EntityObject

The EntityObject to save.

Returns

IObservable<Unit>

A instance of IConnectableObservable

DisableAuditTrail()

Disables the audit trail functionality for the current data context.

public void DisableAuditTrail()

DisableSystemMode()

Sets the Model of a DataContext to a state where entities/properties that have either System or ApplicationSpecific cannot be changed anymore. This is the default behavior.

public void DisableSystemMode()

Dispose()

Releases database connection.

public void Dispose()

EnableAuditTrail()

Enables the audit trail functionality for the current data context.

public void EnableAuditTrail()

EnableSystemMode()

Sets the Model of a DataContext to a state where entities/properties that have either System or ApplicationSpecific can be changed.

public void EnableSystemMode()

Remarks

ATTENTION: Use the system model at your own risk and only if you know what you are doing! Changes to System or ApplicationSpecific may break the Model.

A newly created DataContext is never in system mode! So nobody can temper with System or ApplicationSpecific entities accidentially.

EnforceRefreshModel()

Refreshes Model by reading it from the underlying metadata database

public void EnforceRefreshModel()

Remarks

In contrast to RefreshModel() this method always reads the Model from the underlying metadata database regardless of the local model version. Therefore it can be used to throw away pending model changes in memory.

ExecuteAction(ModelAction, ExecutionContext)

Execute the given action.

public ActionResult ExecuteAction(ModelAction action, ExecutionContext executionContext)

Parameters

action ModelAction

Action to execute.

executionContext ExecutionContext

Execution context/parameters to use.

Returns

ActionResult

Action result.

GetMember(String)

Gets a dynamic member.

public override object GetMember(string name)

Parameters

name String

Name of the member or method to get.

Returns

Object

Reference to the dynamic member.

Remarks

In most cases this method is used in dynamic language code. In a dynamic language, GetMember(String) must not be called on a DataContext. It suffices to call e.g. Context.Select(query). A lookup for the member with name "Select" is performed. Ths method provides access to the following members: Select(String, SelectCache), Select(String, IEnumerable<QueryParameter>, SelectCache), SelectSingle(String, SelectCache), SelectSingle(String, IEnumerable<QueryParameter>, SelectCache), SaveModel(Model), SaveObject(EntityObject), GetWritableModel(), RefreshModel(), , DbClient.BeginTransaction() and DbClient.TryCommitTransaction.

Select methods that should be called with a list of parameters must end with the "WithParams" prfix in a dynamic language. So to call SelectSingle(String, IEnumerable<QueryParameter>, SelectCache) from a script the correct statement is SelectSingleWithParams(query, params).

In order to create new instance of EntityObjects, this method provides a custom syntax. It suffices to call CreateModelEntityName in a dynamic language, whereas the prefix "Create" indicates that a new instance of the ModelEntityBase with the name "ModelEntityName" should be created. # create ModelEntity projectType = ModelEntity({ "Name": "Project", "InvariantFriendlyName": "Timecockpit Project" }) projectType.Properties.Add(TextProperty({ "Name": "ProjectName", "MaxStorageSize": 50, "InvariantFriendlyName":"Project Name" })) # create instance of ModelEntity instance = Context.CreateProject()

GetMetaObject(Expression)

Gets the data context meta object.

public override DynamicMetaObject GetMetaObject(Expression parameter)

Parameters

parameter Expression

Expression parameter.

Returns

DynamicMetaObject

Meta object.

GetScriptListResultAsync(ScriptListRequest)

Gets the result of a script source list.

public Task<EntityObject[]> GetScriptListResultAsync(ScriptListRequest request)

Parameters

request ScriptListRequest

Request: List name, parameters ...

Returns

Task<EntityObject[]>

Returns the task representing the operation and containing the result entity objects.

GetScriptResultByListName(String, String, IEnumerable<QueryParameter>, String)

Selects the name of the by list.

public ICollection<EntityObject> GetScriptResultByListName(string listName, string methodName, IEnumerable<QueryParameter> queryParameters, string condition = null)

Parameters

listName String

Name of the list.

methodName String

Name of the method.

queryParameters IEnumerable<QueryParameter>

The query parameters.

condition String

Additional query condition.

Returns

ICollection<EntityObject>

A list of EntityObjects.

GetScriptResultModelEntityByListName(String, String)

Gets the result model entity for the specified list.

public ModelEntityBase GetScriptResultModelEntityByListName(string listName, string methodName)

Parameters

listName String

Name of the list.

methodName String

Name of the method.

Returns

ModelEntityBase

A list of EntityObjects.

GetSettings(ConnectionInformation, DataContextSettings)

TODO review/preview

public static DataContextSettings GetSettings(ConnectionInformation connectionInformation, DataContextSettings settings)

Parameters

connectionInformation ConnectionInformation
settings DataContextSettings

Returns

DataContextSettings

GetVersionInformation(String, String, String, String)

Gets the version information for the current user/tenant.

public static VersionInformationOverview GetVersionInformation(string userName, string password, string endpointName, string endpointAddress = null)

Parameters

userName String

The username to access the management webservice.

password String

The password to access the management webservice.

endpointName String

The name of the service endpoint where to access the management service.

endpointAddress String

The address of the endpoint to use.

Returns

VersionInformationOverview

The version information for the current user/tenant or null if the user uses a deprecated (pre-ownership) tenant.

GetWritableModel()

Gets a Model from the metadata repository database that is not frozen (i.e. that can be changed)

public Model GetWritableModel()

Returns

Model

An instance of Model where metadata can be changed.

Exceptions

System.InvalidOperationException

InitializeLocalizedTextValues(EntityObject)

Initializes the localized text values.

public void InitializeLocalizedTextValues(EntityObject entityObject)

Parameters

entityObject EntityObject

The entity object to initialize the localized text value collection for.

Remarks

If called, the method creates the structure to store localized text values of a new entity object. If the method is called on an EntityObject that has been loaded from the database the method throws an System.InvalidOperationException.

IsDirty(EntityObject)

Checks if an EntityObject has changed since it has been loaded from the database.

public bool IsDirty(EntityObject entityObject)

Parameters

entityObject EntityObject

The EntityObject to check.

Returns

Boolean

True if the EntityObject has been changed since it has been loaded from the database else false.

ReadLocalizedTextValues(EntityObject)

Reads the localized text values for all localized properties of the underlying ModelEntityBase of the EntityObject.

public void ReadLocalizedTextValues(EntityObject entityObject)

Parameters

entityObject EntityObject

The entity object.

RefreshEnvironment()

Refreshes the environment.

public void RefreshEnvironment()

RefreshModel()

Refreshes the Model by reading it from the underlying metadata database

public void RefreshModel()

Remarks

Before reading the Model from the database the system verifies that the Model in the database has changed. This is done by comparing the local model version from the database with the property LocalModelVersion from Model.

SaveChanges(ChangeTracker)

The method takes an instance of a ChangeTracker and persists the EntityObjects that have been tracked by the instance. The method persists both, add/update or delete operations.

public int SaveChanges(ChangeTracker tracker)

Parameters

tracker ChangeTracker

The tracker.

Returns

Int32

An int that indicates how many changes have been saved

SaveChangesAsync(ChangeTracker)

Saves a given EntityObject.

[Obsolete("Avoid until task based implementation becomes available.")]
public IObservable<int> SaveChangesAsync(ChangeTracker tracker)

Parameters

tracker ChangeTracker

The tracker for which to save the content.

Returns

IObservable<Int32>

A instance of IConnectableObservable

SaveModel(Model)

Saves all Model.PendingOperations in the underlying model.

public void SaveModel(Model model)

Parameters

model Model

The Model to save.

SaveModelIfValid(Model)

Saves all Model.PendingOperations in the underlying model after validating that the model is valid.

public void SaveModelIfValid(Model model)

Parameters

model Model

The Model to save.

Remarks

Please be aware that a model might already be invalid before the currently pending operations were enqueued. If there is no guarantee/check that the initial model was valid, this method might throw a ValidationException even though the currently pending operations did not cause new issues.

SaveObject(EntityObject)

Saves a given EntityObject.

public void SaveObject(EntityObject entityObject)

Parameters

entityObject EntityObject

The EntityObject to save.

SaveObject(EntityObject, SaveSettings)

Saves a given EntityObject.

public void SaveObject(EntityObject entityObject, SaveSettings settings)

Parameters

entityObject EntityObject

The EntityObject to save.

settings SaveSettings

Settings to use for the save operation.

SaveObjectAsync(EntityObject)

Saves a given EntityObject.

[Obsolete("Avoid until task based implementation becomes available.")]
public IObservable<Unit> SaveObjectAsync(EntityObject entityObject)

Parameters

entityObject EntityObject

The EntityObject to save.

Returns

IObservable<Unit>

A instance of IConnectableObservable

Select(String, IEnumerable<QueryParameter>, SelectCache)

Executes a query with query parameters.

public ICollection<EntityObject> Select(string query, IEnumerable<QueryParameter> queryParameters, SelectCache cache = null)

Parameters

query String

Query to execute

queryParameters IEnumerable<QueryParameter>

A list of System.Collections.Generic.IEnumerable<T>

cache SelectCache

The entity object cache for reusing entities.

Returns

ICollection<EntityObject>

A list of EntityObjects

Select(String, SelectCache)

Executes a query

public ICollection<EntityObject> Select(string query, SelectCache cache = null)

Parameters

query String

Query to execute.

cache SelectCache

The entity object cache for reusing entities.

Returns

ICollection<EntityObject>

A list of EntityObjects.

Select(Query, IEnumerable<QueryParameter>, SelectCache)

Executes a query with query parameters by passing in an AST tree.

public ICollection<EntityObject> Select(Query query, IEnumerable<QueryParameter> queryParameters, SelectCache cache = null)

Parameters

query Query

Query to execute as an AST representation.

queryParameters IEnumerable<QueryParameter>

A list of System.Collections.Generic.IEnumerable<T>

cache SelectCache

The entity object cache for reusing entities.

Returns

ICollection<EntityObject>

A list of EntityObjects

Select(Query, SelectCache)

Executes a query passed as an AST.

public ICollection<EntityObject> Select(Query query, SelectCache cache = null)

Parameters

query Query

The query to select.

cache SelectCache

The entity object cache for reusing entities.

Returns

ICollection<EntityObject>

Returns a list of EntityObjects.

SelectAsync(String, IEnumerable<QueryParameter>, SelectCache)

public IObservable<EntityObject> SelectAsync(string query, IEnumerable<QueryParameter> queryParameters, SelectCache cache = null)

Parameters

query String

a TCQL query

queryParameters IEnumerable<QueryParameter>

a list of QueryParameters

cache SelectCache

The entity object cache for reusing entities.

Returns

IObservable<EntityObject>

An connectable observable of EntityObjects.

SelectAsync(String, SelectCache)

Invokes the Select(String, SelectCache) method asynchronously

[Obsolete("Avoid until task based implementation becomes available.")]
public IObservable<EntityObject> SelectAsync(string query, SelectCache cache = null)

Parameters

query String

a TCQL query

cache SelectCache

The entity object cache for reusing entities.

Returns

IObservable<EntityObject>

returns a connectable observable producing the entity objects returned by the query.

SelectAsync(Query, IEnumerable<QueryParameter>, SelectCache)

Invokes the asynchronously.

public IObservable<EntityObject> SelectAsync(Query query, IEnumerable<QueryParameter> queryParameters, SelectCache cache = null)

Parameters

query Query

The AST representation of a Query.

queryParameters IEnumerable<QueryParameter>

a list of QueryParameters

cache SelectCache

The entity object cache for reusing entities.

Returns

IObservable<EntityObject>

An connectable observable of EntityObjects.

SelectMultipleAsync(QueryRequest[], CancellationToken)

Issues multiple queries.

public Task SelectMultipleAsync(QueryRequest[] queries, CancellationToken cancellationToken)

Parameters

queries QueryRequest[]

The queries to execute.

cancellationToken CancellationToken

The cancellation token to cancel requests.

Returns

Task

Returns the tasks producing the results of the queries, in corresponding order.

SelectSingle(String, IEnumerable<QueryParameter>, SelectCache)

Executes a query with a list of QueryParameters and returns the first row of the result set

public EntityObject SelectSingle(string query, IEnumerable<QueryParameter> queryParameters, SelectCache cache = null)

Parameters

query String

Query to execute

queryParameters IEnumerable<QueryParameter>

A list of System.Collections.Generic.IEnumerable<T>.

cache SelectCache

The entity object cache for reusing entities.

Returns

EntityObject

A list of EntityObjects.

SelectSingle(String, SelectCache)

Executes a query and returns the first row of the result set.

public EntityObject SelectSingle(string query, SelectCache cache = null)

Parameters

query String

Query to execute.

cache SelectCache

The entity object cache for reusing entities.

Returns

EntityObject

A single instance of EntityObject.

SelectSingle(IEntityObject, Boolean, SelectCache)

Executes a query by example and returns the first row of the result set

public EntityObject SelectSingle(IEntityObject entityObject, bool autoIncludeRelations, SelectCache cache = null)

Parameters

entityObject IEntityObject

The example EntityObject to query for.

autoIncludeRelations Boolean

If true, fetches the all relations of the EntityObject

cache SelectCache

The entity object cache for reusing entities.

Returns

EntityObject

A single instance of EntityObject.

Remarks

This method returns the all relations of the returned EntityObject. That is, if an EntityObject has a relation to another EntityObject and the referenced EntityObject has a value, the value will be returned.

SelectSingle(IEntityObject, SelectCache)

Executes a query by example and returns the first row of the result set

public EntityObject SelectSingle(IEntityObject entityObject, SelectCache cache = null)

Parameters

entityObject IEntityObject

The example EntityObject to query for.

cache SelectCache

The entity object cache for reusing entities.

Returns

EntityObject

An instance of EntityObject.

Remarks

This does not fetch include relations in the query. That is, if an EntityObject has a relation to another EntityObject, the value of the referenced EntityObject will be null.

SelectSingle(Query, IEnumerable<QueryParameter>, SelectCache)

Executes a query returning a single element.

public EntityObject SelectSingle(Query query, IEnumerable<QueryParameter> queryParameters, SelectCache cache = null)

Parameters

query Query

The query to execute.

queryParameters IEnumerable<QueryParameter>

The query parameters to execute.

cache SelectCache

The entity object cache for reusing entities.

Returns

EntityObject

Returns the entity object returned by the query.

SelectSingle(Query, SelectCache)

Executes a query and returns the first row of the result set.

public EntityObject SelectSingle(Query query, SelectCache cache = null)

Parameters

query Query

Query to execute.

cache SelectCache

The entity object cache for reusing entities.

Returns

EntityObject

A single instance of EntityObject.

SelectSingleAsync(String, IEnumerable<QueryParameter>, SelectCache)

public IObservable<EntityObject> SelectSingleAsync(string query, IEnumerable<QueryParameter> queryParameters, SelectCache cache = null)

Parameters

query String

a TCQL query

queryParameters IEnumerable<QueryParameter>

a list of QueryParameters

cache SelectCache

The entity object cache for reusing entities.

Returns

IObservable<EntityObject>

Returns a connectable observable of EntityObjects.

SelectSingleAsync(String, SelectCache)

Invokes the SelectSingle(String, SelectCache) method asynchronously

public IObservable<EntityObject> SelectSingleAsync(string query, SelectCache cache = null)

Parameters

query String

a TCQL query

cache SelectCache

The entity object cache for reusing entities.

Returns

IObservable<EntityObject>

Returns a connectable observable of EntityObjects.

SelectSingleAsync(IEntityObject)

Executes a query by example and returns the first row of the result set

public IObservable<EntityObject> SelectSingleAsync(IEntityObject entityObject)

Parameters

entityObject IEntityObject

The example EntityObject to query for.

Returns

IObservable<EntityObject>

An instance of EntityObject.

Remarks

This does not fetch include relations in the query. That is, if an EntityObject has a relation to another EntityObject, the value of the referenced EntityObject will be null.

SelectSingleAsync(IEntityObject, Boolean, SelectCache)

Executes a query by example and returns the first row of the result set

public IObservable<EntityObject> SelectSingleAsync(IEntityObject entityObject, bool autoIncludeRelations, SelectCache cache = null)

Parameters

entityObject IEntityObject

The example EntityObject to query for.

autoIncludeRelations Boolean

If true, fetches the all relations of the EntityObject

cache SelectCache

The entity object cache for reusing entities.

Returns

IObservable<EntityObject>

A single instance of EntityObject.

Remarks

This method returns the all relations of the returned EntityObject. That is, if an EntityObject has a relation to another EntityObject and the referenced EntityObject has a value, the value will be returned.

SelectSingleAsync(Query, IEnumerable<QueryParameter>)

Invokes the asynchronously.

public IObservable<EntityObject> SelectSingleAsync(Query query, IEnumerable<QueryParameter> queryParameters)

Parameters

query Query

The AST representation of a Query.

queryParameters IEnumerable<QueryParameter>

a list of QueryParameters

Returns

IObservable<EntityObject>

An connectable observable producing an EntityObject.

SelectSingleWithParameters(IEnumerable<KeyValuePair<Object, Object>>)

Executes a query with query parameters and returns the first row of the result set

public EntityObject SelectSingleWithParameters(IEnumerable<KeyValuePair<object, object>> parameters)

Parameters

parameters IEnumerable<KeyValuePair<Object, Object>>

A list of System.Collections.Generic.KeyValuePair<TKey, TValue>.

Returns

EntityObject

A single instance of EntityObject.

SelectSingleWithParametersAsync(IEnumerable<KeyValuePair<Object, Object>>)

Execute a query with query parameters asynchronously and returns an observable to the first row of the result set.

public IObservable<EntityObject> SelectSingleWithParametersAsync(IEnumerable<KeyValuePair<object, object>> parameters)

Parameters

parameters IEnumerable<KeyValuePair<Object, Object>>

A list of System.Collections.Generic.KeyValuePair<TKey, TValue>.

Returns

IObservable<EntityObject>

An observable to a single instance of EntityObjects

SelectTop(String, Int32, IEnumerable<QueryParameter>, SelectCache)

Executes a query with a list of QueryParameters and returns a specified number of rows.

public ICollection<EntityObject> SelectTop(string query, int rowCount, IEnumerable<QueryParameter> queryParameters, SelectCache cache = null)

Parameters

query String

Query to execute.

rowCount Int32

The number rows to return.

queryParameters IEnumerable<QueryParameter>

A list of System.Collections.Generic.IEnumerable<T>.

cache SelectCache

The entity object cache for reusing entities.

Returns

ICollection<EntityObject>

A list of EntityObjects

SelectTop(String, Int32, SelectCache)

Executes a query but returns only the specified number of rows.

public ICollection<EntityObject> SelectTop(string query, int rowCount, SelectCache cache = null)

Parameters

query String

Query to execute.

rowCount Int32

The number of rows to return.

cache SelectCache

The entity object cache for reusing entities.

Returns

ICollection<EntityObject>

A list of EntityObjects.

SelectTopAsync(String, Int32, IEnumerable<QueryParameter>, SelectCache)

Executes a query with a list of QueryParameters and returns a specified number of rows.

public IObservable<EntityObject> SelectTopAsync(string query, int rowCount, IEnumerable<QueryParameter> queryParameters, SelectCache cache = null)

Parameters

query String

Query to execute.

rowCount Int32

The number rows to return.

queryParameters IEnumerable<QueryParameter>

A list of System.Collections.Generic.IEnumerable<T>.

cache SelectCache

The entity object cache for reusing entities.

Returns

IObservable<EntityObject>

Returns a connectable observable of EntityObjects.

SelectTopAsync(String, Int32, SelectCache)

Executes a query asynchronously but returns only the specified number of rows.

public IObservable<EntityObject> SelectTopAsync(string query, int rowCount, SelectCache cache = null)

Parameters

query String

Query to execute asynchronously.

rowCount Int32

The number of rows to return.

cache SelectCache

The entity object cache for reusing entities.

Returns

IObservable<EntityObject>

A list of EntityObjects.

SelectWithParameters(IEnumerable<KeyValuePair<Object, Object>>)

Executes a query with query parameters.

public ICollection<EntityObject> SelectWithParameters(IEnumerable<KeyValuePair<object, object>> parameters)

Parameters

parameters IEnumerable<KeyValuePair<Object, Object>>

A list of System.Collections.Generic.KeyValuePair<TKey, TValue>.

Returns

ICollection<EntityObject>

A list of EntityObjects

Explicit Interface Implementations

IDataContext.DeleteObjectAsync(EntityObject)

Asynchronously deletes an object.

Task IDataContext.DeleteObjectAsync(EntityObject entityObject)

Parameters

entityObject EntityObject

The id and type of the entity to delete.

Returns

Task

Returns the task representing the operation.

IDataContext.Localizer

Gets the localizer.

NameLocalizer IDataContext.Localizer { get; }

Returns

NameLocalizer

IDataContext.Model

Gets the model of the context.

Model IDataContext.Model { get; }

Returns

Model

IDataContext.SaveChangesAsync(ChangeTracker)

Saves the changes from the change tracker to the data context.

Task IDataContext.SaveChangesAsync(ChangeTracker changes)

Parameters

changes ChangeTracker

The ChangeTracker holding the changed objects.

Returns

Task

Returns the task representing the operation.

IDataContext.SaveObjectAsync(EntityObject)

Saves an object to the data context.

Task IDataContext.SaveObjectAsync(EntityObject entityObject)

Parameters

entityObject EntityObject

The entity object to save.

Returns

Task

Returns the task representing the operation.

IDataContext.SelectMultipleAsync(QueryRequest[], CancellationToken)

Canonical method for querying a database with multiple queries at the same time.

Task IDataContext.SelectMultipleAsync(QueryRequest[] queries, CancellationToken cancellationToken)

Parameters

queries QueryRequest[]

The query request objects.

cancellationToken CancellationToken

A cancellation token used for all operations.

Returns

Task

Returns a list of tasks representing the query operations.

Remarks

This interface is the lowest level interface and should support all scenarios required. Use the helper methods in to find an easier interface.