/// <summary> /// Save List /// </summary> /// <param name="helper">Sql Helper</param> virtual public void Save(SqlHelper helper) { try { bool isDeletedItem = false; foreach (T entity in Items) { if (entity.IsDeleted) { isDeletedItem = true; } EntityBaseReadOnly currentEntity = entity as EntityBaseReadOnly; currentEntity.Save(helper); } if (isDeletedItem) { for (int i = Items.Count - 1; i >= 0; i--) { if (Items[i].IsDeleted) { Items.RemoveAt(i); } } } } catch { throw; } }
/// <summary> /// Hydration method /// </summary> /// <param name="view">View</param> internal virtual void Initialize(System.Data.DataView view) { foreach (DataRowView rowView in view) { T entity = EntityBaseReadOnly.GetEntityInstance <T>(); entity.Initialize(rowView); base.Add(entity); } }
/// <summary> /// Hydration method /// </summary> /// <param name="reader">Reader</param> internal virtual void Initialize(System.Data.IDataReader reader) { while (reader.Read()) { T entity = EntityBaseReadOnly.GetEntityInstance <T>(); entity.Initialize(reader); base.Add(entity); } }
/// <summary> /// Hydration method /// </summary> /// <param name="parent">Parent Entity</param> /// <param name="reader">Reader</param> internal virtual void Initialize(System.Collections.IList parent, System.Data.IDataReader reader) { while (reader.Read()) { T entity = EntityBaseReadOnly.GetEntityInstance <T>(); entity.Initialize(reader); entity.Parent = parent; base.Add(entity); } }
/// <summary> /// Hydration method /// </summary> /// <param name="parent">Parent Entity</param> /// <param name="view">View</param> internal virtual void Initialize(System.Collections.IList parent, System.Data.DataView view) { foreach (DataRowView rowView in view) { T entity = EntityBaseReadOnly.GetEntityInstance <T>(); entity.Initialize(rowView); entity.Parent = parent; base.Add(entity); } }
/// <summary> /// Get Entity by Id /// </summary> /// <param name="id">Id</param> /// <returns>Entity</returns> public EntityBaseReadOnly GetEntityById(string uniqueIdentifer) { EntityBaseReadOnly returnValue = null; foreach (T tEntity in this) { if (tEntity is EntityBaseReadOnly) { EntityBaseReadOnly entity = tEntity as EntityBaseReadOnly; if (entity.UniqueIdentifier == uniqueIdentifer) { returnValue = entity; break; } } } return(returnValue); }
/// <summary> /// Initialize New /// </summary> /// <typeparam name="T"></typeparam> /// <returns></returns> internal static T InitializeNew <T>() where T : EntityBase { T entity = EntityBaseReadOnly.GetEntityInstance <T>(); System.Type entityType = entity.GetType(); List <ColumnInfo> defaultValues = ColumnInfo.GetColumnInfoDefaultValues(entityType); foreach (ColumnInfo column in defaultValues) { PropertyInfo propertyInfo = GetDatabaseColumnPropertyInfo(entityType, column.ColumnName); if (propertyInfo != null) { SetPropertyValueIfNotNull(entity, propertyInfo, column.Value); } } entity.IsNew = true; entity.IsDirty = true; return(entity); }
/// <summary> /// Public constructor taking the entity and a helper /// </summary> public EntityCancelEventArgs(EntityBaseReadOnly entity, SqlHelper helper) { this._entity = entity; this._helper = helper; }
/// <summary> /// Constructor /// </summary> /// <param name="parent">Parent Entity</param> /// <param name="reader">Reader</param> internal EntityList(EntityBaseReadOnly parent, System.Data.IDataReader reader) : base(parent, reader) { }
/// <summary> /// Constructor /// </summary> /// <param name="parent">Parent Entity</param> internal EntityList(EntityBaseReadOnly parent) : base(parent) { }
/// <summary> /// Public constructor taking the entity and a helper /// </summary> public EntityException(string message, Exception innerException, EntityBaseReadOnly entity, SqlHelper helper) : this(message, innerException) { this._entity = entity; this._helper = helper; }
/// <summary> /// Constructor /// </summary> /// <param name="parent">Parent Entity</param> /// <param name="table">Data Table</param> internal EntityList(EntityBaseReadOnly parent, System.Data.DataTable table) : base(parent, table) { }
/// <summary> /// Public constructor taking the entity /// </summary> public EntityCancelEventArgs(EntityBaseReadOnly entity) { this._entity = entity; }
/// <summary> /// Constructor /// </summary> /// <param name="parent">Parent Entity</param> /// <param name="reader">Reader</param> internal EntityListReadOnly(EntityBaseReadOnly parent, System.Data.IDataReader reader) : this(reader) { this.parent = parent; }
/// <summary> /// Constructor /// </summary> /// <param name="parent">Parent Entity</param> internal EntityListReadOnly(EntityBaseReadOnly parent) { this.parent = parent; }
/// <summary> /// Public constructor taking the entity and a helper /// </summary> public EntityException(EntityBaseReadOnly entity, SqlHelper helper) : this() { this._entity = entity; this._helper = helper; }
/// <summary> /// Constructor /// </summary> /// <param name="parent">Parent Entity</param> /// <param name="table">Data Table</param> internal EntityListReadOnly(EntityBaseReadOnly parent, System.Data.DataTable table) : this(table) { this.parent = parent; }
/// <summary> /// Public constructor taking the entity /// </summary> public EntityException(EntityBaseReadOnly entity) : this() { this._entity = entity; }
/// <summary> /// Public constructor taking the entity /// </summary> public EntityException(string message, Exception innerException, EntityBaseReadOnly entity) : this(message, innerException) { this._entity = entity; }