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