/// <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); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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); }
/// <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)); }
/// <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); }
/// <summary> /// Creates new copy of entity object. /// </summary> protected TEntity Clone <TEntity>() where TEntity : Entity, new() { return(EntityMechanic <TEntity> .Clone((TEntity)this)); }
/// <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); }
/// <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); }
/// <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)); }
/// <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)); }
/// <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)); }