/// <summary>
        /// Entity property set method.
        /// </summary>
        public static void Set <TParent>(ref TEntity memberEntity, TParent parentEntity, TEntity valueEntity, string propertyName) where TParent : Entity, new()
        {
            // Set primary key values.
            EntityMechanic <TEntity> .SetPrimaryKeyParameters(parentEntity, valueEntity, propertyName);

            // Set member entity value.
            memberEntity = valueEntity;
        }
        /// <summary>
        /// Entity property get method.
        /// </summary>
        /// <returns>Entity object</returns>
        public static TEntity Get <TParent>(ref TEntity memberEntity, TParent parentEntity, string propertyName) where TParent : Entity, new()
        {
            // If member entity not null return same object.
            if (memberEntity != null)
            {
                return(memberEntity);
            }

            // Get property primary key parameter values.
            object[] newPkparameters = EntityMechanic <TEntity> .GetPrimaryKeyParameters(memberEntity, parentEntity, propertyName);

            memberEntity = EntityMechanic <TEntity> .GetByPrimaryKey(newPkparameters);

            return(memberEntity);
        }
Beispiel #3
0
 /// <summary>
 /// Returns collection of entites given query condition.
 /// </summary>
 protected static IEnumerable <TEntity> GetByAny <TEntity>(string columnName, QueryOp queryOp, object value) where TEntity : Entity, new()
 {
     return(EntityMechanic <TEntity> .GetByAny(columnName, queryOp, value));
 }
Beispiel #4
0
 /// <summary>
 /// Returns single entity object (or null) from database given primary key value.
 /// </summary>
 protected static async Task <TEntity> TryGetByPrimaryKeyAsync <TEntity>(params object[] parameters) where TEntity : Entity, new()
 {
     return(await EntityMechanic <TEntity> .GetByPrimaryKeyAsync(parameters));
 }
Beispiel #5
0
 /// <summary>
 /// Returns single entity object (or null) from database given unique key value.
 /// </summary>
 protected static TEntity TryGetByCallingParameters <TEntity>(params object[] parameters) where TEntity : Entity, new()
 {
     return(EntityMechanic <TEntity> .GetByUniqueKey(parameters));
 }
Beispiel #6
0
 /// <summary>
 /// Returns collection of entites given query conditions.
 /// </summary>
 protected static IEnumerable <TEntity> GetByAny <TEntity>(params QueryCondition[] queryConditions) where TEntity : Entity, new()
 {
     return(EntityMechanic <TEntity> .GetByAny(queryConditions));
 }
Beispiel #7
0
 /// <summary>
 /// Validates entity object against in memory copy of database constraints.
 /// </summary>
 /// <typeparam name="TEntity">Type of entity. Eg. Person, Customer ...</typeparam>
 protected void Validate <TEntity>() where TEntity : Entity, new()
 {
     EntityMechanic <TEntity> .ValidateEntity(this);
 }
Beispiel #8
0
 /// <summary>
 /// Returns single entity object (or null) from database given primary key value.
 /// </summary>
 protected static TEntity TryGetByPrimaryKey <TEntity>(params object[] parameters) where TEntity : Entity, new()
 {
     return(EntityMechanic <TEntity> .GetByPrimaryKey(parameters));
 }
Beispiel #9
0
 /// <summary>
 /// Deletes entity object from database.
 /// </summary>
 /// <typeparam name="TEntity">Type of entity. Eg. Person, Customer ...</typeparam>
 protected async Task DeleteAsync <TEntity>() where TEntity : Entity, new()
 {
     await EntityMechanic <TEntity> .DeleteEntityAsync(this);
 }
Beispiel #10
0
 /// <summary>
 /// Creates new copy of entity object.
 /// </summary>
 protected TEntity Clone <TEntity>() where TEntity : Entity, new()
 {
     return(EntityMechanic <TEntity> .Clone((TEntity)this));
 }
Beispiel #11
0
 /// <summary>
 /// Deletes entity object from database.
 /// </summary>
 /// <typeparam name="TEntity">Type of entity. Eg. Person, Customer ...</typeparam>
 protected void Delete <TEntity>() where TEntity : Entity, new()
 {
     EntityMechanic <TEntity> .DeleteEntity(this);
 }
Beispiel #12
0
 /// <summary>
 /// Saves entity object to database.
 /// </summary>
 /// <typeparam name="TEntity">Type of entity. Eg. Person, Customer ...</typeparam>
 protected void Save <TEntity>() where TEntity : Entity, new()
 {
     EntityMechanic <TEntity> .SaveEntity(this);
 }
Beispiel #13
0
 /// <summary>
 /// Returns collection of entites given query condition.
 /// </summary>
 protected static async Task <IEnumerable <TEntity> > GetByAnyAsync <TEntity>(string columnName, QueryOp queryOp, object value) where TEntity : Entity, new()
 {
     return(await EntityMechanic <TEntity> .GetByAnyAsync(columnName, queryOp, value));
 }
Beispiel #14
0
 /// <summary>
 /// Returns collection of entites given query conditions.
 /// </summary>
 protected static async Task <IEnumerable <TEntity> > GetByAnyAsync <TEntity>(params QueryCondition[] queryConditions) where TEntity : Entity, new()
 {
     return(await EntityMechanic <TEntity> .GetByAnyAsync(queryConditions));
 }
Beispiel #15
0
 /// <summary>
 /// Returns single entity object (or null) from database given unique key value.
 /// </summary>
 protected static async Task <TEntity> TryGetByCallingParametersAsync <TEntity>(params object[] parameters) where TEntity : Entity, new()
 {
     return(await EntityMechanic <TEntity> .GetByUniqueKeyAsync(parameters));
 }