Class ModelEntity<TObject>
Generic Class for Model Objects. Extend this class to any new Class that needs to have Persistance. This class will inherit the CRUD basic operations.
Inheritance
Inherited Members
Namespace:UM4RS
Assembly:UM4RS.dll
Syntax
public abstract class ModelEntity<TObject> : IDisposable where TObject : class, IBaseEntity
Type Parameters
| Name | Description |
|---|---|
| TObject |
Methods
Count()
Gets the count of the number of objects in the database
Declaration
public static int Count()
Returns
| Type | Description |
|---|---|
| System.Int32 | The count of the number of objects |
Remarks
Synchronous
CountAsync()
Gets the count of the number of objects in the database
Declaration
public static Task<int> CountAsync()
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<TResult><System.Int32> | The count of the number of objects |
Remarks
Asynchronous
Delete(TObject)
Deletes a single object from the database and commits the change
Declaration
public static void Delete(TObject t)
Parameters
| Type | Name | Description |
|---|---|---|
| TObject | t | The object to delete |
Remarks
Synchronous
DeleteAsync(TObject)
Deletes a single object from the database and commits the change
Declaration
public Task<int> DeleteAsync(TObject t)
Parameters
| Type | Name | Description |
|---|---|---|
| TObject | t | The object to delete |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<TResult><System.Int32> |
Remarks
Asynchronous
Dispose()
Declaration
public virtual void Dispose()
Implements
Find(Expression<Func<TObject, Boolean>>)
Returns a single object which matches the provided expression
Declaration
public static TObject Find(Expression<Func<TObject, bool>> match)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Linq.Expressions.Expression<TDelegate><System.Func`2<TObject, System.Boolean>> | match | A Linq expression filter to find a single result |
Returns
| Type | Description |
|---|---|
| TObject | A single object which matches the expression filter. If more than one object is found or if zero are found, null is returned |
Remarks
Synchronous
FindAll(Expression<Func<TObject, Boolean>>)
Returns a collection of objects which match the provided expression
Declaration
public static ICollection<TObject> FindAll(Expression<Func<TObject, bool>> match)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Linq.Expressions.Expression<TDelegate><System.Func`2<TObject, System.Boolean>> | match | A linq expression filter to find one or more results |
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.ICollection<T><TObject> | An ICollection of object which match the expression filter |
Remarks
Synchronous
FindAllAsync(Expression<Func<TObject, Boolean>>)
Returns a collection of objects which match the provided expression
Declaration
public static Task<ICollection<TObject>> FindAllAsync(Expression<Func<TObject, bool>> match)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Linq.Expressions.Expression<TDelegate><System.Func`2<TObject, System.Boolean>> | match | A linq expression filter to find one or more results |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<TResult><System.Collections.Generic.ICollection<T><TObject>> | An ICollection of object which match the expression filter |
Remarks
Asynchronous
FindAsync(Expression<Func<TObject, Boolean>>)
Returns a single object which matches the provided expression
Declaration
public static Task<TObject> FindAsync(Expression<Func<TObject, bool>> match)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Linq.Expressions.Expression<TDelegate><System.Func`2<TObject, System.Boolean>> | match | A Linq expression filter to find a single result |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<TResult><TObject> | A single object which matches the expression filter. If more than one object is found or if zero are found, null is returned |
Remarks
Asynchronous
Get(Int32)
Returns a single object with a primary key of the provided id
Declaration
public static TObject Get(int id)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | id | The primary key of the object to fetch |
Returns
| Type | Description |
|---|---|
| TObject | A single object with the provided primary key or null |
Remarks
Synchronous
Get(Expression<Func<TObject, Boolean>>, Expression<Func<TObject, Object>>[])
Returns a ICollection of objects that fullfil the provided query
Declaration
public static ICollection<TObject> Get(Expression<Func<TObject, bool>> query, params Expression<Func<TObject, object>>[] nagivationProperties)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Linq.Expressions.Expression<TDelegate><System.Func`2<TObject, System.Boolean>> | query | The query to search for |
| System.Linq.Expressions.Expression<TDelegate><System.Func`2<TObject, System.Object>>[] | nagivationProperties |
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.ICollection<T><TObject> | The of objects that fullfil the query |
GetAll()
Gets a collection of all objects in the database
Declaration
public static ICollection<TObject> GetAll()
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.ICollection<T><TObject> | An ICollection of every object in the database |
Remarks
Synchronous
GetAllAsync()
Gets a collection of all objects in the database
Declaration
public static Task<ICollection<TObject>> GetAllAsync()
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<TResult><System.Collections.Generic.ICollection<T><TObject>> | An ICollection of every object in the database |
Remarks
Asynchronous
GetAsync(Int32)
Returns a single object with a primary key of the provided id
Declaration
public static Task<TObject> GetAsync(int id)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | id | The primary key of the object to fetch |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<TResult><TObject> | A single object with the provided primary key or null |
Remarks
Asynchronous
Save()
Save the current objecto to database
Declaration
public virtual void Save()
Save(TObject)
Saves a new or modified object into the database and commits the change
Declaration
public static TObject Save(TObject t)
Parameters
| Type | Name | Description |
|---|---|---|
| TObject | t | The object to Save |
Returns
| Type | Description |
|---|---|
| TObject | The resulting object including its primary key after the Save |
Remarks
Synchronous
SaveAllAsync(IEnumerable<TObject>)
Inserts a collection of objects into the database and commits the changes
Declaration
public static Task<IEnumerable<TObject>> SaveAllAsync(IEnumerable<TObject> tList)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<T><TObject> | tList | An IEnumerable list of objects to insert |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<TResult><System.Collections.Generic.IEnumerable<T><TObject>> | The IEnumerable resulting list of inserted objects including the primary keys |
Remarks
Asynchronous
SaveAsync(TObject)
Inserts a single object to the database and commits the change
Declaration
public static Task<TObject> SaveAsync(TObject t)
Parameters
| Type | Name | Description |
|---|---|---|
| TObject | t | The object to insert |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<TResult><TObject> | The resulting object including its primary key after the insert |
Remarks
Asynchronous
SavedAll(IEnumerable<TObject>)
Inserts a collection of objects into the database and commits the changes
Declaration
public static IEnumerable<TObject> SavedAll(IEnumerable<TObject> tList)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<T><TObject> | tList | An IEnumerable list of objects to insert |
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable<T><TObject> | The IEnumerable resulting list of inserted objects including the primary keys |
Remarks
Synchronous