/// <summary>
        /// Fill a TList&lt;Store&gt; From a DataReader.
        /// </summary>
        /// <param name="reader">Datareader</param>
        /// <param name="rows">The collection to fill</param>
        /// <param name="start">Row number at which to start reading, the first row is 0.</param>
        /// <param name="pageLength">number of rows.</param>
        /// <returns>a <see cref="TList&lt;Store&gt;"/></returns>
        public static TList <Store> Fill(IDataReader reader, TList <Store> rows, int start, int pageLength)
        {
            NetTiersProvider currentProvider           = DataRepository.Provider;
            bool             useEntityFactory          = currentProvider.UseEntityFactory;
            bool             enableEntityTracking      = currentProvider.EnableEntityTracking;
            LoadPolicy       currentLoadPolicy         = currentProvider.CurrentLoadPolicy;
            Type             entityCreationFactoryType = currentProvider.EntityCreationalFactoryType;

            // advance to the starting row
            for (int i = 0; i < start; i++)
            {
                if (!reader.Read())
                {
                    return(rows);            // not enough rows, just return
                }
            }
            for (int i = 0; i < pageLength; i++)
            {
                if (!reader.Read())
                {
                    break;                     // we are done
                }
                string key = null;

                LibraryManagement.Domain.Store c = null;
                if (useEntityFactory)
                {
                    key = new System.Text.StringBuilder("Store")
                          .Append("|").Append((System.String)reader[((int)StoreColumn.Id - 1)]).ToString();
                    c = EntityManager.LocateOrCreate <Store>(
                        key.ToString(),            // EntityTrackingKey
                        "Store",                   //Creational Type
                        entityCreationFactoryType, //Factory used to create entity
                        enableEntityTracking);     // Track this entity?
                }
                else
                {
                    c = new LibraryManagement.Domain.Store();
                }

                if (!enableEntityTracking ||
                    c.EntityState == EntityState.Added ||
                    (enableEntityTracking &&

                     (
                         (currentLoadPolicy == LoadPolicy.PreserveChanges && c.EntityState == EntityState.Unchanged) ||
                         (currentLoadPolicy == LoadPolicy.DiscardChanges && c.EntityState != EntityState.Unchanged)
                     )
                    ))
                {
                    c.SuppressEntityEvents = true;
                    c.Id                = (System.String)reader[((int)StoreColumn.Id - 1)];
                    c.OriginalId        = c.Id;
                    c.Type              = (reader.IsDBNull(((int)StoreColumn.Type - 1)))?null:(System.String)reader[((int)StoreColumn.Type - 1)];
                    c.Name              = (reader.IsDBNull(((int)StoreColumn.Name - 1)))?null:(System.String)reader[((int)StoreColumn.Name - 1)];
                    c.Fullname          = (reader.IsDBNull(((int)StoreColumn.Fullname - 1)))?null:(System.String)reader[((int)StoreColumn.Fullname - 1)];
                    c.Address           = (reader.IsDBNull(((int)StoreColumn.Address - 1)))?null:(System.String)reader[((int)StoreColumn.Address - 1)];
                    c.Phone             = (reader.IsDBNull(((int)StoreColumn.Phone - 1)))?null:(System.String)reader[((int)StoreColumn.Phone - 1)];
                    c.Fax               = (reader.IsDBNull(((int)StoreColumn.Fax - 1)))?null:(System.String)reader[((int)StoreColumn.Fax - 1)];
                    c.Bankname          = (reader.IsDBNull(((int)StoreColumn.Bankname - 1)))?null:(System.String)reader[((int)StoreColumn.Bankname - 1)];
                    c.BankBr            = (reader.IsDBNull(((int)StoreColumn.BankBr - 1)))?null:(System.String)reader[((int)StoreColumn.BankBr - 1)];
                    c.Accnum            = (reader.IsDBNull(((int)StoreColumn.Accnum - 1)))?null:(System.String)reader[((int)StoreColumn.Accnum - 1)];
                    c.Vatnum            = (reader.IsDBNull(((int)StoreColumn.Vatnum - 1)))?null:(System.String)reader[((int)StoreColumn.Vatnum - 1)];
                    c.Contactps         = (reader.IsDBNull(((int)StoreColumn.Contactps - 1)))?null:(System.String)reader[((int)StoreColumn.Contactps - 1)];
                    c.Remark            = (reader.IsDBNull(((int)StoreColumn.Remark - 1)))?null:(System.String)reader[((int)StoreColumn.Remark - 1)];
                    c.OpenDate          = (reader.IsDBNull(((int)StoreColumn.OpenDate - 1)))?null:(System.DateTime?)reader[((int)StoreColumn.OpenDate - 1)];
                    c.Status            = (System.Boolean)reader[((int)StoreColumn.Status - 1)];
                    c.EntityTrackingKey = key;
                    c.AcceptChanges();
                    c.SuppressEntityEvents = false;
                }
                rows.Add(c);
            }
            return(rows);
        }
Esempio n. 2
0
        /// <summary>
        /// Fill a TList&lt;Currency&gt; From a DataReader.
        /// </summary>
        /// <param name="reader">Datareader</param>
        /// <param name="rows">The collection to fill</param>
        /// <param name="start">Row number at which to start reading, the first row is 0.</param>
        /// <param name="pageLength">number of rows.</param>
        /// <returns>a <see cref="TList&lt;Currency&gt;"/></returns>
        public static TList <Currency> Fill(IDataReader reader, TList <Currency> rows, int start, int pageLength)
        {
            NetTiersProvider currentProvider           = DataRepository.Provider;
            bool             useEntityFactory          = currentProvider.UseEntityFactory;
            bool             enableEntityTracking      = currentProvider.EnableEntityTracking;
            LoadPolicy       currentLoadPolicy         = currentProvider.CurrentLoadPolicy;
            Type             entityCreationFactoryType = currentProvider.EntityCreationalFactoryType;

            // advance to the starting row
            for (int i = 0; i < start; i++)
            {
                if (!reader.Read())
                {
                    return(rows);            // not enough rows, just return
                }
            }
            for (int i = 0; i < pageLength; i++)
            {
                if (!reader.Read())
                {
                    break;                     // we are done
                }
                string key = null;

                LibraryManagement.Domain.Currency c = null;
                if (useEntityFactory)
                {
                    key = new System.Text.StringBuilder("Currency")
                          .Append("|").Append((System.String)reader[((int)CurrencyColumn.Id - 1)]).ToString();
                    c = EntityManager.LocateOrCreate <Currency>(
                        key.ToString(),              // EntityTrackingKey
                        "Currency",                  //Creational Type
                        entityCreationFactoryType,   //Factory used to create entity
                        enableEntityTracking);       // Track this entity?
                }
                else
                {
                    c = new LibraryManagement.Domain.Currency();
                }

                if (!enableEntityTracking ||
                    c.EntityState == EntityState.Added ||
                    (enableEntityTracking &&

                     (
                         (currentLoadPolicy == LoadPolicy.PreserveChanges && c.EntityState == EntityState.Unchanged) ||
                         (currentLoadPolicy == LoadPolicy.DiscardChanges && c.EntityState != EntityState.Unchanged)
                     )
                    ))
                {
                    c.SuppressEntityEvents = true;
                    c.Id                = (System.String)reader[((int)CurrencyColumn.Id - 1)];
                    c.OriginalId        = c.Id;
                    c.Description       = (reader.IsDBNull(((int)CurrencyColumn.Description - 1)))?null:(System.String)reader[((int)CurrencyColumn.Description - 1)];
                    c.Exchange          = (reader.IsDBNull(((int)CurrencyColumn.Exchange - 1)))?null:(System.Decimal?)reader[((int)CurrencyColumn.Exchange - 1)];
                    c.Status            = (reader.IsDBNull(((int)CurrencyColumn.Status - 1)))?null:(System.Boolean?)reader[((int)CurrencyColumn.Status - 1)];
                    c.EntityTrackingKey = key;
                    c.AcceptChanges();
                    c.SuppressEntityEvents = false;
                }
                rows.Add(c);
            }
            return(rows);
        }
        /// <summary>
        /// Fill a TList&lt;CsCard&gt; From a DataReader.
        /// </summary>
        /// <param name="reader">Datareader</param>
        /// <param name="rows">The collection to fill</param>
        /// <param name="start">Row number at which to start reading, the first row is 0.</param>
        /// <param name="pageLength">number of rows.</param>
        /// <returns>a <see cref="TList&lt;CsCard&gt;"/></returns>
        public static TList <CsCard> Fill(IDataReader reader, TList <CsCard> rows, int start, int pageLength)
        {
            NetTiersProvider currentProvider           = DataRepository.Provider;
            bool             useEntityFactory          = currentProvider.UseEntityFactory;
            bool             enableEntityTracking      = currentProvider.EnableEntityTracking;
            LoadPolicy       currentLoadPolicy         = currentProvider.CurrentLoadPolicy;
            Type             entityCreationFactoryType = currentProvider.EntityCreationalFactoryType;

            // advance to the starting row
            for (int i = 0; i < start; i++)
            {
                if (!reader.Read())
                {
                    return(rows);            // not enough rows, just return
                }
            }
            for (int i = 0; i < pageLength; i++)
            {
                if (!reader.Read())
                {
                    break;                     // we are done
                }
                string key = null;

                LibraryManagement.Domain.CsCard c = null;
                if (useEntityFactory)
                {
                    key = new System.Text.StringBuilder("CsCard")
                          .Append("|").Append((System.String)reader[((int)CsCardColumn.CardId - 1)]).ToString();
                    c = EntityManager.LocateOrCreate <CsCard>(
                        key.ToString(),            // EntityTrackingKey
                        "CsCard",                  //Creational Type
                        entityCreationFactoryType, //Factory used to create entity
                        enableEntityTracking);     // Track this entity?
                }
                else
                {
                    c = new LibraryManagement.Domain.CsCard();
                }

                if (!enableEntityTracking ||
                    c.EntityState == EntityState.Added ||
                    (enableEntityTracking &&

                     (
                         (currentLoadPolicy == LoadPolicy.PreserveChanges && c.EntityState == EntityState.Unchanged) ||
                         (currentLoadPolicy == LoadPolicy.DiscardChanges && c.EntityState != EntityState.Unchanged)
                     )
                    ))
                {
                    c.SuppressEntityEvents = true;
                    c.CardId            = (System.String)reader[((int)CsCardColumn.CardId - 1)];
                    c.OriginalCardId    = c.CardId;
                    c.IsVip             = (reader.IsDBNull(((int)CsCardColumn.IsVip - 1)))?null:(System.Boolean?)reader[((int)CsCardColumn.IsVip - 1)];
                    c.CsSex             = (reader.IsDBNull(((int)CsCardColumn.CsSex - 1)))?null:(System.Boolean?)reader[((int)CsCardColumn.CsSex - 1)];
                    c.PersonId          = (reader.IsDBNull(((int)CsCardColumn.PersonId - 1)))?null:(System.String)reader[((int)CsCardColumn.PersonId - 1)];
                    c.Birthday          = (reader.IsDBNull(((int)CsCardColumn.Birthday - 1)))?null:(System.DateTime?)reader[((int)CsCardColumn.Birthday - 1)];
                    c.PsIssuedate       = (reader.IsDBNull(((int)CsCardColumn.PsIssuedate - 1)))?null:(System.DateTime?)reader[((int)CsCardColumn.PsIssuedate - 1)];
                    c.PsPlaceissuse     = (reader.IsDBNull(((int)CsCardColumn.PsPlaceissuse - 1)))?null:(System.String)reader[((int)CsCardColumn.PsPlaceissuse - 1)];
                    c.Fullname          = (System.String)reader[((int)CsCardColumn.Fullname - 1)];
                    c.Address           = (System.String)reader[((int)CsCardColumn.Address - 1)];
                    c.Phone             = (reader.IsDBNull(((int)CsCardColumn.Phone - 1)))?null:(System.String)reader[((int)CsCardColumn.Phone - 1)];
                    c.Email             = (reader.IsDBNull(((int)CsCardColumn.Email - 1)))?null:(System.String)reader[((int)CsCardColumn.Email - 1)];
                    c.DiscPc            = (reader.IsDBNull(((int)CsCardColumn.DiscPc - 1)))?null:(System.Decimal?)reader[((int)CsCardColumn.DiscPc - 1)];
                    c.IssDate           = (reader.IsDBNull(((int)CsCardColumn.IssDate - 1)))?null:(System.DateTime?)reader[((int)CsCardColumn.IssDate - 1)];
                    c.DueDate           = (reader.IsDBNull(((int)CsCardColumn.DueDate - 1)))?null:(System.DateTime?)reader[((int)CsCardColumn.DueDate - 1)];
                    c.Image             = (reader.IsDBNull(((int)CsCardColumn.Image - 1)))?null:(System.Byte[])reader[((int)CsCardColumn.Image - 1)];
                    c.Remark            = (reader.IsDBNull(((int)CsCardColumn.Remark - 1)))?null:(System.String)reader[((int)CsCardColumn.Remark - 1)];
                    c.Begmark           = (reader.IsDBNull(((int)CsCardColumn.Begmark - 1)))?null:(System.Decimal?)reader[((int)CsCardColumn.Begmark - 1)];
                    c.Endmark           = (reader.IsDBNull(((int)CsCardColumn.Endmark - 1)))?null:(System.Decimal?)reader[((int)CsCardColumn.Endmark - 1)];
                    c.Status            = (System.Boolean)reader[((int)CsCardColumn.Status - 1)];
                    c.EntityTrackingKey = key;
                    c.AcceptChanges();
                    c.SuppressEntityEvents = false;
                }
                rows.Add(c);
            }
            return(rows);
        }
        /// <summary>
        /// Fill a TList&lt;BookAttr&gt; From a DataReader.
        /// </summary>
        /// <param name="reader">Datareader</param>
        /// <param name="rows">The collection to fill</param>
        /// <param name="start">Row number at which to start reading, the first row is 0.</param>
        /// <param name="pageLength">number of rows.</param>
        /// <returns>a <see cref="TList&lt;BookAttr&gt;"/></returns>
        public static TList <BookAttr> Fill(IDataReader reader, TList <BookAttr> rows, int start, int pageLength)
        {
            NetTiersProvider currentProvider           = DataRepository.Provider;
            bool             useEntityFactory          = currentProvider.UseEntityFactory;
            bool             enableEntityTracking      = currentProvider.EnableEntityTracking;
            LoadPolicy       currentLoadPolicy         = currentProvider.CurrentLoadPolicy;
            Type             entityCreationFactoryType = currentProvider.EntityCreationalFactoryType;

            // advance to the starting row
            for (int i = 0; i < start; i++)
            {
                if (!reader.Read())
                {
                    return(rows);            // not enough rows, just return
                }
            }
            for (int i = 0; i < pageLength; i++)
            {
                if (!reader.Read())
                {
                    break;                     // we are done
                }
                string key = null;

                LibraryManagement.Domain.BookAttr c = null;
                if (useEntityFactory)
                {
                    key = new System.Text.StringBuilder("BookAttr")
                          .Append("|").Append((System.String)reader[((int)BookAttrColumn.GoodsId - 1)]).ToString();
                    c = EntityManager.LocateOrCreate <BookAttr>(
                        key.ToString(),              // EntityTrackingKey
                        "BookAttr",                  //Creational Type
                        entityCreationFactoryType,   //Factory used to create entity
                        enableEntityTracking);       // Track this entity?
                }
                else
                {
                    c = new LibraryManagement.Domain.BookAttr();
                }

                if (!enableEntityTracking ||
                    c.EntityState == EntityState.Added ||
                    (enableEntityTracking &&

                     (
                         (currentLoadPolicy == LoadPolicy.PreserveChanges && c.EntityState == EntityState.Unchanged) ||
                         (currentLoadPolicy == LoadPolicy.DiscardChanges && c.EntityState != EntityState.Unchanged)
                     )
                    ))
                {
                    c.SuppressEntityEvents = true;
                    c.GoodsId           = (System.String)reader[((int)BookAttrColumn.GoodsId - 1)];
                    c.OriginalGoodsId   = c.GoodsId;
                    c.Author            = (System.String)reader[((int)BookAttrColumn.Author - 1)];
                    c.Publish           = (System.String)reader[((int)BookAttrColumn.Publish - 1)];
                    c.Translator        = (System.String)reader[((int)BookAttrColumn.Translator - 1)];
                    c.FormType          = (System.Int32)reader[((int)BookAttrColumn.FormType - 1)];
                    c.Language          = (System.Int32)reader[((int)BookAttrColumn.Language - 1)];
                    c.PlMonth           = (System.Int32)reader[((int)BookAttrColumn.PlMonth - 1)];
                    c.PlYear            = (System.Int32)reader[((int)BookAttrColumn.PlYear - 1)];
                    c.Dimension         = (System.String)reader[((int)BookAttrColumn.Dimension - 1)];
                    c.Weight            = (System.Int32)reader[((int)BookAttrColumn.Weight - 1)];
                    c.Pages             = (System.Int32)reader[((int)BookAttrColumn.Pages - 1)];
                    c.Introinfo         = (System.String)reader[((int)BookAttrColumn.Introinfo - 1)];
                    c.EntityTrackingKey = key;
                    c.AcceptChanges();
                    c.SuppressEntityEvents = false;
                }
                rows.Add(c);
            }
            return(rows);
        }
Esempio n. 5
0
        /// <summary>
        /// Fill a TList&lt;PaymentOrder&gt; From a DataReader.
        /// </summary>
        /// <param name="reader">Datareader</param>
        /// <param name="rows">The collection to fill</param>
        /// <param name="start">Row number at which to start reading, the first row is 0.</param>
        /// <param name="pageLength">number of rows.</param>
        /// <returns>a <see cref="TList&lt;PaymentOrder&gt;"/></returns>
        public static TList <PaymentOrder> Fill(IDataReader reader, TList <PaymentOrder> rows, int start, int pageLength)
        {
            NetTiersProvider currentProvider           = DataRepository.Provider;
            bool             useEntityFactory          = currentProvider.UseEntityFactory;
            bool             enableEntityTracking      = currentProvider.EnableEntityTracking;
            LoadPolicy       currentLoadPolicy         = currentProvider.CurrentLoadPolicy;
            Type             entityCreationFactoryType = currentProvider.EntityCreationalFactoryType;

            // advance to the starting row
            for (int i = 0; i < start; i++)
            {
                if (!reader.Read())
                {
                    return(rows);            // not enough rows, just return
                }
            }
            for (int i = 0; i < pageLength; i++)
            {
                if (!reader.Read())
                {
                    break;                     // we are done
                }
                string key = null;

                LibraryManagement.Domain.PaymentOrder c = null;
                if (useEntityFactory)
                {
                    key = new System.Text.StringBuilder("PaymentOrder")
                          .Append("|").Append((System.String)reader[((int)PaymentOrderColumn.TransNum - 1)]).ToString();
                    c = EntityManager.LocateOrCreate <PaymentOrder>(
                        key.ToString(),                 // EntityTrackingKey
                        "PaymentOrder",                 //Creational Type
                        entityCreationFactoryType,      //Factory used to create entity
                        enableEntityTracking);          // Track this entity?
                }
                else
                {
                    c = new LibraryManagement.Domain.PaymentOrder();
                }

                if (!enableEntityTracking ||
                    c.EntityState == EntityState.Added ||
                    (enableEntityTracking &&

                     (
                         (currentLoadPolicy == LoadPolicy.PreserveChanges && c.EntityState == EntityState.Unchanged) ||
                         (currentLoadPolicy == LoadPolicy.DiscardChanges && c.EntityState != EntityState.Unchanged)
                     )
                    ))
                {
                    c.SuppressEntityEvents = true;
                    c.TransNum             = (System.String)reader[((int)PaymentOrderColumn.TransNum - 1)];
                    c.OriginalTransNum     = c.TransNum;
                    c.Payer             = (System.String)reader[((int)PaymentOrderColumn.Payer - 1)];
                    c.PayerAcc          = (System.String)reader[((int)PaymentOrderColumn.PayerAcc - 1)];
                    c.PayerBank         = (System.String)reader[((int)PaymentOrderColumn.PayerBank - 1)];
                    c.PayerBranch       = (System.String)reader[((int)PaymentOrderColumn.PayerBranch - 1)];
                    c.Benef             = (System.String)reader[((int)PaymentOrderColumn.Benef - 1)];
                    c.BenefAcc          = (System.String)reader[((int)PaymentOrderColumn.BenefAcc - 1)];
                    c.BenefBank         = (System.String)reader[((int)PaymentOrderColumn.BenefBank - 1)];
                    c.BenefBranch       = (System.String)reader[((int)PaymentOrderColumn.BenefBranch - 1)];
                    c.Amount            = (System.Decimal)reader[((int)PaymentOrderColumn.Amount - 1)];
                    c.EntityTrackingKey = key;
                    c.AcceptChanges();
                    c.SuppressEntityEvents = false;
                }
                rows.Add(c);
            }
            return(rows);
        }
        /// <summary>
        /// Fill a TList&lt;AccTrans&gt; From a DataReader.
        /// </summary>
        /// <param name="reader">Datareader</param>
        /// <param name="rows">The collection to fill</param>
        /// <param name="start">Row number at which to start reading, the first row is 0.</param>
        /// <param name="pageLength">number of rows.</param>
        /// <returns>a <see cref="TList&lt;AccTrans&gt;"/></returns>
        public static TList <AccTrans> Fill(IDataReader reader, TList <AccTrans> rows, int start, int pageLength)
        {
            NetTiersProvider currentProvider           = DataRepository.Provider;
            bool             useEntityFactory          = currentProvider.UseEntityFactory;
            bool             enableEntityTracking      = currentProvider.EnableEntityTracking;
            LoadPolicy       currentLoadPolicy         = currentProvider.CurrentLoadPolicy;
            Type             entityCreationFactoryType = currentProvider.EntityCreationalFactoryType;

            // advance to the starting row
            for (int i = 0; i < start; i++)
            {
                if (!reader.Read())
                {
                    return(rows);            // not enough rows, just return
                }
            }
            for (int i = 0; i < pageLength; i++)
            {
                if (!reader.Read())
                {
                    break;                     // we are done
                }
                string key = null;

                LibraryManagement.Domain.AccTrans c = null;
                if (useEntityFactory)
                {
                    key = new System.Text.StringBuilder("AccTrans")
                          .Append("|").Append((System.Decimal)reader[((int)AccTransColumn.Id - 1)]).ToString();
                    c = EntityManager.LocateOrCreate <AccTrans>(
                        key.ToString(),              // EntityTrackingKey
                        "AccTrans",                  //Creational Type
                        entityCreationFactoryType,   //Factory used to create entity
                        enableEntityTracking);       // Track this entity?
                }
                else
                {
                    c = new LibraryManagement.Domain.AccTrans();
                }

                if (!enableEntityTracking ||
                    c.EntityState == EntityState.Added ||
                    (enableEntityTracking &&

                     (
                         (currentLoadPolicy == LoadPolicy.PreserveChanges && c.EntityState == EntityState.Unchanged) ||
                         (currentLoadPolicy == LoadPolicy.DiscardChanges && c.EntityState != EntityState.Unchanged)
                     )
                    ))
                {
                    c.SuppressEntityEvents = true;
                    c.Id                = (System.Decimal)reader[((int)AccTransColumn.Id - 1)];
                    c.TranDate          = (System.DateTime)reader[((int)AccTransColumn.TranDate - 1)];
                    c.TranTime          = (reader.IsDBNull(((int)AccTransColumn.TranTime - 1)))?null:(System.String)reader[((int)AccTransColumn.TranTime - 1)];
                    c.EfDate            = (reader.IsDBNull(((int)AccTransColumn.EfDate - 1)))?null:(System.DateTime?)reader[((int)AccTransColumn.EfDate - 1)];
                    c.TransNum          = (System.String)reader[((int)AccTransColumn.TransNum - 1)];
                    c.Voucher           = (System.String)reader[((int)AccTransColumn.Voucher - 1)];
                    c.TransCode         = (System.String)reader[((int)AccTransColumn.TransCode - 1)];
                    c.AccountId         = (System.String)reader[((int)AccTransColumn.AccountId - 1)];
                    c.DbAmount          = (System.Decimal)reader[((int)AccTransColumn.DbAmount - 1)];
                    c.CrAmount          = (System.Decimal)reader[((int)AccTransColumn.CrAmount - 1)];
                    c.UserId            = (System.Decimal)reader[((int)AccTransColumn.UserId - 1)];
                    c.CorrAcc           = (System.String)reader[((int)AccTransColumn.CorrAcc - 1)];
                    c.Remark            = (System.String)reader[((int)AccTransColumn.Remark - 1)];
                    c.Name              = (reader.IsDBNull(((int)AccTransColumn.Name - 1)))?null:(System.String)reader[((int)AccTransColumn.Name - 1)];
                    c.Address           = (reader.IsDBNull(((int)AccTransColumn.Address - 1)))?null:(System.String)reader[((int)AccTransColumn.Address - 1)];
                    c.PersonId          = (reader.IsDBNull(((int)AccTransColumn.PersonId - 1)))?null:(System.String)reader[((int)AccTransColumn.PersonId - 1)];
                    c.Updated           = (System.Boolean)reader[((int)AccTransColumn.Updated - 1)];
                    c.Recnum            = (reader.IsDBNull(((int)AccTransColumn.Recnum - 1)))?null:(System.Decimal?)reader[((int)AccTransColumn.Recnum - 1)];
                    c.Status            = (System.Boolean)reader[((int)AccTransColumn.Status - 1)];
                    c.EntityTrackingKey = key;
                    c.AcceptChanges();
                    c.SuppressEntityEvents = false;
                }
                rows.Add(c);
            }
            return(rows);
        }
        /// <summary>
        /// Fill a TList&lt;Account&gt; From a DataReader.
        /// </summary>
        /// <param name="reader">Datareader</param>
        /// <param name="rows">The collection to fill</param>
        /// <param name="start">Row number at which to start reading, the first row is 0.</param>
        /// <param name="pageLength">number of rows.</param>
        /// <returns>a <see cref="TList&lt;Account&gt;"/></returns>
        public static TList <Account> Fill(IDataReader reader, TList <Account> rows, int start, int pageLength)
        {
            NetTiersProvider currentProvider           = DataRepository.Provider;
            bool             useEntityFactory          = currentProvider.UseEntityFactory;
            bool             enableEntityTracking      = currentProvider.EnableEntityTracking;
            LoadPolicy       currentLoadPolicy         = currentProvider.CurrentLoadPolicy;
            Type             entityCreationFactoryType = currentProvider.EntityCreationalFactoryType;

            // advance to the starting row
            for (int i = 0; i < start; i++)
            {
                if (!reader.Read())
                {
                    return(rows);            // not enough rows, just return
                }
            }
            for (int i = 0; i < pageLength; i++)
            {
                if (!reader.Read())
                {
                    break;                     // we are done
                }
                string key = null;

                LibraryManagement.Domain.Account c = null;
                if (useEntityFactory)
                {
                    key = new System.Text.StringBuilder("Account")
                          .Append("|").Append((System.Decimal)reader[((int)AccountColumn.Branch - 1)])
                          .Append("|").Append((System.String)reader[((int)AccountColumn.AccountId - 1)]).ToString();
                    c = EntityManager.LocateOrCreate <Account>(
                        key.ToString(),             // EntityTrackingKey
                        "Account",                  //Creational Type
                        entityCreationFactoryType,  //Factory used to create entity
                        enableEntityTracking);      // Track this entity?
                }
                else
                {
                    c = new LibraryManagement.Domain.Account();
                }

                if (!enableEntityTracking ||
                    c.EntityState == EntityState.Added ||
                    (enableEntityTracking &&

                     (
                         (currentLoadPolicy == LoadPolicy.PreserveChanges && c.EntityState == EntityState.Unchanged) ||
                         (currentLoadPolicy == LoadPolicy.DiscardChanges && c.EntityState != EntityState.Unchanged)
                     )
                    ))
                {
                    c.SuppressEntityEvents = true;
                    c.Branch            = (System.Decimal)reader[((int)AccountColumn.Branch - 1)];
                    c.OriginalBranch    = c.Branch;
                    c.AccountId         = (System.String)reader[((int)AccountColumn.AccountId - 1)];
                    c.OriginalAccountId = c.AccountId;
                    c.Abbreviat         = (System.String)reader[((int)AccountColumn.Abbreviat - 1)];
                    c.MofGl             = (System.String)reader[((int)AccountColumn.MofGl - 1)];
                    c.CustId            = (System.String)reader[((int)AccountColumn.CustId - 1)];
                    c.Name              = (System.String)reader[((int)AccountColumn.Name - 1)];
                    c.OpenDate          = (System.DateTime)reader[((int)AccountColumn.OpenDate - 1)];
                    c.PrevDate          = (System.DateTime)reader[((int)AccountColumn.PrevDate - 1)];
                    c.LastDate          = (System.DateTime)reader[((int)AccountColumn.LastDate - 1)];
                    c.Creamt            = (System.Decimal)reader[((int)AccountColumn.Creamt - 1)];
                    c.Debamt            = (System.Decimal)reader[((int)AccountColumn.Debamt - 1)];
                    c.Status            = (System.Boolean)reader[((int)AccountColumn.Status - 1)];
                    c.EntityTrackingKey = key;
                    c.AcceptChanges();
                    c.SuppressEntityEvents = false;
                }
                rows.Add(c);
            }
            return(rows);
        }