Webiant Logo Webiant Logo
  1. No results found.

    Try your search with a different keyword or use * as a wildcard.

INopDataProvider.cs

using System.Linq.Expressions;
using LinqToDB.Data;
using Nop.Core;

namespace Nop.Data;

/// 
/// Represents a data provider
/// 
public partial interface INopDataProvider
{
    #region Methods

    /// 
    /// Create the database
    /// 
    /// Collation
    /// Count of tries to connect to the database after creating; set 0 if no need to connect after creating
    void CreateDatabase(string collation, int triesToConnect = 10);

    /// 
    /// Creates a new temporary storage and populate it using data from provided query
    /// 
    /// Name of temporary storage
    /// Query to get records to populate created storage with initial data
    /// Storage record mapping class
    /// 
    /// A task that represents the asynchronous operation
    /// The task result contains the iQueryable instance of temporary storage
    /// 
    Task> CreateTempDataStorageAsync(string storeKey, IQueryable query)
        where TItem : class;

    /// 
    /// Initialize database
    /// 
    void InitializeDatabase();

    /// 
    /// Insert a new entity
    /// 
    /// Entity type
    /// Entity
    /// 
    /// A task that represents the asynchronous operation
    /// The task result contains the entity
    /// 
    Task InsertEntityAsync(TEntity entity) where TEntity : BaseEntity;

    /// 
    /// Insert a new entity
    /// 
    /// Entity type
    /// Entity
    /// Entity
    TEntity InsertEntity(TEntity entity) where TEntity : BaseEntity;

    /// 
    /// Updates record in table, using values from entity parameter. 
    /// Record to update identified by match on primary key value from obj value.
    /// 
    /// Entity with data to update
    /// Entity type
    /// A task that represents the asynchronous operation
    Task UpdateEntityAsync(TEntity entity) where TEntity : BaseEntity;

    /// 
    /// Updates record in table, using values from entity parameter. 
    /// Record to update identified by match on primary key value from obj value.
    /// 
    /// Entity with data to update
    /// Entity type
    void UpdateEntity(TEntity entity) where TEntity : BaseEntity;

    /// 
    /// Updates records in table, using values from entity parameter. 
    /// Records to update are identified by match on primary key value from obj value.
    /// 
    /// Entities with data to update
    /// Entity type
    /// A task that represents the asynchronous operation
    Task UpdateEntitiesAsync(IEnumerable entities) where TEntity : BaseEntity;

    /// 
    /// Updates records in table, using values from entity parameter. 
    /// Records to update are identified by match on primary key value from obj value.
    /// 
    /// Entities with data to update
    /// Entity type
    void UpdateEntities(IEnumerable entities) where TEntity : BaseEntity;

    /// 
    /// Deletes record in table. Record to delete identified
    /// by match on primary key value from obj value.
    /// 
    /// Entity for delete operation
    /// Entity type
    /// A task that represents the asynchronous operation
    Task DeleteEntityAsync(TEntity entity) where TEntity : BaseEntity;

    /// 
    /// Deletes record in table. Record to delete identified
    /// by match on primary key value from obj value.
    /// 
    /// Entity for delete operation
    /// Entity type
    void DeleteEntity(TEntity entity) where TEntity : BaseEntity;

    /// 
    /// Performs delete records in a table
    /// 
    /// Entities for delete operation
    /// Entity type
    /// A task that represents the asynchronous operation
    Task BulkDeleteEntitiesAsync(IList entities) where TEntity : BaseEntity;

    /// 
    /// Performs delete records in a table
    /// 
    /// Entities for delete operation
    /// Entity type
    void BulkDeleteEntities(IList entities) where TEntity : BaseEntity;

    /// 
    /// Performs delete records in a table by a condition
    /// 
    /// A function to test each element for a condition.
    /// Entity type
    /// 
    /// A task that represents the asynchronous operation
    /// The task result contains the number of deleted records
    /// 
    Task BulkDeleteEntitiesAsync(Expression> predicate) where TEntity : BaseEntity;

    /// 
    /// Performs delete records in a table by a condition
    /// 
    /// A function to test each element for a condition.
    /// Entity type
    /// 
    /// The number of deleted records
    /// 
    int BulkDeleteEntities(Expression> predicate) where TEntity : BaseEntity;

    /// 
    /// Performs bulk insert entities operation
    /// 
    /// Entity type
    /// Collection of Entities
    /// A task that represents the asynchronous operation
    Task BulkInsertEntitiesAsync(IEnumerable entities) where TEntity : BaseEntity;

    /// 
    /// Performs bulk insert entities operation
    /// 
    /// Entity type
    /// Collection of Entities
    void BulkInsertEntities(IEnumerable entities) where TEntity : BaseEntity;

    /// 
    /// Gets the name of a foreign key
    /// 
    /// Foreign key table
    /// Foreign key column name
    /// Primary table
    /// Primary key column name
    /// Name of a foreign key
    string CreateForeignKeyName(string foreignTable, string foreignColumn, string primaryTable, string primaryColumn);

    /// 
    /// Gets the name of an index
    /// 
    /// Target table name
    /// Target column name
    /// Name of an index
    string GetIndexName(string targetTable, string targetColumn);

    /// 
    /// Returns queryable source for specified mapping class for current connection,
    /// mapped to database table or view.
    /// 
    /// Entity type
    /// Queryable source
    IQueryable GetTable() where TEntity : BaseEntity;

    /// 
    /// Get the current identity value
    /// 
    /// Entity
    /// 
    /// A task that represents the asynchronous operation
    /// The task result contains the integer identity; null if cannot get the result
    /// 
    Task GetTableIdentAsync() where TEntity : BaseEntity;

    /// 
    /// Checks if the specified database exists, returns true if database exists
    /// 
    /// 
    /// A task that represents the asynchronous operation
    /// The task result contains the returns true if the database exists.
    /// 
    Task DatabaseExistsAsync();

    /// 
    /// Checks if the specified database exists, returns true if database exists
    /// 
    /// Returns true if the database exists.
    bool DatabaseExists();

    /// 
    /// Creates a backup of the database
    /// 
    /// A task that represents the asynchronous operation
    Task BackupDatabaseAsync(string fileName);

    /// 
    /// Restores the database from a backup
    /// 
    /// The name of the backup file
    /// A task that represents the asynchronous operation
    Task RestoreDatabaseAsync(string backupFileName);

    /// 
    /// Re-index database tables
    /// 
    /// A task that represents the asynchronous operation
    Task ReIndexTablesAsync();

    /// 
    /// Build the connection string
    /// 
    /// Connection string info
    /// Connection string
    string BuildConnectionString(INopConnectionStringInfo nopConnectionString);

    /// 
    /// Set table identity (is supported)
    /// 
    /// Entity
    /// Identity value
    /// A task that represents the asynchronous operation
    Task SetTableIdentAsync(int ident) where TEntity : BaseEntity;

    /// 
    /// Get hash values of a stored entity field
    /// 
    /// A function to test each element for a condition.
    /// A key selector which should project to a dictionary key
    /// A field selector to apply a transform to a hash value
    /// Entity type
    /// Dictionary
    Task> GetFieldHashesAsync(Expression> predicate,
        Expression> keySelector,
        Expression> fieldSelector) where TEntity : BaseEntity;

    /// 
    /// Executes command asynchronously and returns number of affected records
    /// 
    /// Command text
    /// Command parameters
    /// 
    /// A task that represents the asynchronous operation
    /// The task result contains the number of records, affected by command execution.
    /// 
    Task ExecuteNonQueryAsync(string sql, params DataParameter[] dataParameters);

    /// 
    /// Executes command using System.Data.CommandType.StoredProcedure command type and
    /// returns results as collection of values of specified type
    /// 
    /// Result record type
    /// Procedure name
    /// Command parameters
    /// 
    /// A task that represents the asynchronous operation
    /// The task result contains the returns collection of query result records
    /// 
    Task> QueryProcAsync(string procedureName, params DataParameter[] parameters);

    /// 
    /// Executes command and returns results as collection of values of specified type
    /// 
    /// Result record type
    /// Command text
    /// Command parameters
    /// 
    /// A task that represents the asynchronous operation
    /// The task result contains the returns collection of query result records
    /// 
    Task> QueryAsync(string sql, params DataParameter[] parameters);

    /// 
    /// Truncates database table
    /// 
    /// Performs reset identity column
    Task TruncateAsync(bool resetIdentity = false) where TEntity : BaseEntity;

    #endregion

    #region Properties

    /// 
    /// Name of database provider
    /// 
    string ConfigurationName { get; }

    /// 
    /// Gets allowed a limit input value of the data for hashing functions, returns 0 if not limited
    /// 
    int SupportedLengthOfBinaryHash { get; }

    /// 
    /// Gets a value indicating whether this data provider supports backup
    /// 
    bool BackupSupported { get; }

    #endregion
}