Class SqlRepositoryBase<TId, TModel>
Sql repository base implementation
Inheritance
System.Object
SqlRepositoryBase<TId, TModel>
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: Simplic.Data.Sql
Assembly: Simplic.Data.Sql.dll
Syntax
public abstract class SqlRepositoryBase<TId, TModel> : IRepositoryBase<TId, TModel>, IModelIdentity<TId, TModel>
Type Parameters
Name | Description |
---|---|
TId | Id |
TModel | Model |
Constructors
| Improve this Doc View SourceSqlRepositoryBase(ISqlService, ISqlColumnService, ICacheService)
Initialize sql service
Declaration
public SqlRepositoryBase(ISqlService sqlService, ISqlColumnService sqlColumnService, ICacheService cacheService)
Parameters
Type | Name | Description |
---|---|---|
ISqlService | sqlService | Sql service |
ISqlColumnService | sqlColumnService | Sql column service |
ICacheService | cacheService | Cache service |
Properties
| Improve this Doc View SourceDifferentColumnNames
Gets a list of different column names
Declaration
public virtual IDictionary<string, string> DifferentColumnNames { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IDictionary<System.String, System.String> |
PrimaryKeyColumn
Gets the current primary column name
Declaration
public abstract string PrimaryKeyColumn { get; }
Property Value
Type | Description |
---|---|
System.String |
TableName
Gets the current table name
Declaration
public abstract string TableName { get; }
Property Value
Type | Description |
---|---|
System.String |
UseCache
Gets or sets whether to use the cache
Declaration
public virtual bool UseCache { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Methods
| Improve this Doc View SourceDelete(TId)
Delete data by id
Declaration
public virtual bool Delete(TId id)
Parameters
Type | Name | Description |
---|---|---|
TId | id | Id of an object to delete |
Returns
Type | Description |
---|---|
System.Boolean | True if successful |
Delete(TModel)
Delete data
Declaration
public virtual bool Delete(TModel obj)
Parameters
Type | Name | Description |
---|---|---|
TModel | obj | Object to delete |
Returns
Type | Description |
---|---|
System.Boolean | True if successful |
Get(TId)
Get data by id
Declaration
public virtual TModel Get(TId id)
Parameters
Type | Name | Description |
---|---|---|
TId | id | Id |
Returns
Type | Description |
---|---|
TModel | Instance of |
GetAll()
Get all objects
Declaration
public virtual IEnumerable<TModel> GetAll()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<TModel> | Enumerable of |
GetAllByColumn<T>(String, T)
Get all objects where a given column value match
Declaration
protected virtual IEnumerable<TModel> GetAllByColumn<T>(string columnName, T id)
Parameters
Type | Name | Description |
---|---|---|
System.String | columnName | |
T | id |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<TModel> | Enumerable of |
Type Parameters
Name | Description |
---|---|
T |
GetByColumn<T>(String, T)
Get a model instance from the database, using a custom column name
Declaration
protected virtual TModel GetByColumn<T>(string columnName, T id)
Parameters
Type | Name | Description |
---|---|---|
System.String | columnName | Column name |
T | id | Id value |
Returns
Type | Description |
---|---|
TModel | Model if exists |
Type Parameters
Name | Description |
---|---|
T | Id type |
GetConnection()
Gets the connection name
Declaration
public string GetConnection()
Returns
Type | Description |
---|---|
System.String | connection name |
GetId(TModel)
Gets the id of a model
Declaration
public abstract TId GetId(TModel obj)
Parameters
Type | Name | Description |
---|---|---|
TModel | obj | Model to get the id of |
Returns
Type | Description |
---|---|
TId | Id value |
Save(TModel)
Create or update data
Declaration
public virtual bool Save(TModel obj)
Parameters
Type | Name | Description |
---|---|---|
TModel | obj | Object to save |
Returns
Type | Description |
---|---|
System.Boolean | True if successful |