예제 #1
0
        /// <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="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>
 /// 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>
        /// 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);
        }
예제 #7
0
        /// <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);
        }
예제 #8
0
 /// <summary>
 /// Public constructor taking the entity
 /// </summary>
 public EntityException(string message, Exception innerException, EntityBaseReadOnly entity) : this(message, innerException)
 {
     this._entity = entity;
 }
예제 #9
0
 /// <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>
 /// <param name="reader">Reader</param>
 internal EntityListReadOnly(EntityBaseReadOnly parent, System.Data.IDataReader reader) : this(reader)
 {
     this.parent = parent;
 }
예제 #11
0
 /// <summary>
 /// Public constructor taking the entity and a helper
 /// </summary>
 public EntityException(EntityBaseReadOnly entity, SqlHelper helper) : this()
 {
     this._entity = entity;
     this._helper = helper;
 }
예제 #12
0
 /// <summary>
 /// Public constructor taking the entity
 /// </summary>
 public EntityEventArgs(EntityBaseReadOnly entity)
 {
     this._entity = entity;
 }
예제 #13
0
 /// <summary>
 /// Public constructor taking the entity and a helper
 /// </summary>
 public EntityEventArgs(EntityBaseReadOnly entity, SqlHelper helper)
 {
     this._entity = entity;
     this._helper = helper;
 }
예제 #14
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="parent">Parent Entity</param>
 internal EntityList(EntityBaseReadOnly parent) : base(parent)
 {
 }
예제 #15
0
 /// <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 EntityListReadOnly(EntityBaseReadOnly parent, System.Data.DataTable table) : this(table)
 {
     this.parent = parent;
 }
예제 #17
0
 /// <summary>
 /// Public constructor taking the entity
 /// </summary>
 public EntityException(EntityBaseReadOnly entity) : this()
 {
     this._entity = entity;
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="parent">Parent Entity</param>
 internal EntityListReadOnly(EntityBaseReadOnly parent)
 {
     this.parent = parent;
 }
예제 #19
0
 /// <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)
 {
 }