Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        protected virtual T BuildEntityFromReader(IDataReader reader)
        {
            T entity = this._entityFactory.BuildEntity(reader);

            // Caso exista algum callback, será percorrida a lista a procura das foreign keys para o preenchimento dos agregados.
            if (this._childCallbacks != null && this._childCallbacks.Count > 0)
            {
                object    childKeyValue = null;
                DataTable columnData    = reader.GetSchemaTable();
                foreach (string childKeyName in this._childCallbacks.Keys)
                {
                    childKeyValue = DataHelper.ReaderContainsColumnName(columnData, childKeyName) ? reader[childKeyName] : null;

                    this._childCallbacks[childKeyName](entity, childKeyValue);
                }
            }

            return(entity);
        }
Exemplo n.º 2
0
        protected virtual T BuildEntityFromReader(IDataReader reader)
        {
            T entity = this.entityFactory.BuildEntity(reader);

            if (this.childCallbacks != null && this.childCallbacks.Count > 0)
            {
                object    childKeyValue = null;
                DataTable columnData    = reader.GetSchemaTable();
                foreach (string childKeyName in this.childCallbacks.Keys)
                {
                    if (DataHelper.ReaderContainsColumnName(columnData, childKeyName))
                    {
                        childKeyValue = reader[childKeyName];
                    }
                    else
                    {
                        childKeyValue = null;
                    }
                    this.childCallbacks[childKeyName](entity, childKeyValue);
                }
            }
            return(entity);
        }