Beispiel #1
0
        public static CustomerObjectCollection DataTableToCollection(DataTable customers)
        {
            CustomerObjectCollection objectsTotal;
            CustomerObjectCollection objects = new CustomerObjectCollection();

            try
            {
                IEnumerator enumerator = null;
                try
                {
                    enumerator = customers.Rows.GetEnumerator();
                    while (enumerator.MoveNext())
                    {
                        DataRow current = (DataRow)enumerator.Current;
                        objects.Add(CustomerRowToObject(current));
                    }
                }
                finally
                {
                    if (enumerator is IDisposable)
                    {
                        (enumerator as IDisposable).Dispose();
                    }
                }
                objectsTotal = objects;
            }
            catch (System.Exception exception1)
            {
                Exception innerException = exception1;
                throw new Exception(MethodBase.GetCurrentMethod().Name, innerException);
            }
            return(objectsTotal);
        }
 public static CustomerObjectCollection DataTableToCollection(DataTable customers)
 {
     CustomerObjectCollection objectsTotal;
     CustomerObjectCollection objects = new CustomerObjectCollection();
     try
     {
         IEnumerator enumerator = null;
         try
         {
             enumerator = customers.Rows.GetEnumerator();
             while (enumerator.MoveNext())
             {
                 DataRow current = (DataRow)enumerator.Current;
                 objects.Add(CustomerRowToObject(current));
             }
         }
         finally
         {
             if (enumerator is IDisposable)
             {
                 (enumerator as IDisposable).Dispose();
             }
         }
         objectsTotal = objects;
     }
     catch (System.Exception exception1)
     {
         Exception innerException = exception1;
         throw new Exception(MethodBase.GetCurrentMethod().Name, innerException);
     }
     return objectsTotal;
 }
 public CustomerObjectCollection GetAll()
 {
     CustomerObjectCollection parameters = new CustomerObjectCollection();
     QueryBuilder builder;
     try
     {
         builder = new QueryBuilder();
         builder.Append(this.BaseQuery(false,0));
         parameters = CustomerConvertor.DataTableToCollection(this.ExecuteDataSet(builder.Query, false).Tables[0]);
     }
     catch (System.Exception exception1)
     {
         throw new Exception(MethodBase.GetCurrentMethod().Name, exception1);
     }
     return parameters;
 }
 public CustomerObjectCollection GetFilter(string name, string vat)
 {
     CustomerObjectCollection customers = new CustomerObjectCollection();
     QueryBuilder builder;
     try
     {
         builder = new QueryBuilder();
         builder.Append(this.BaseQuery(false, 0));
         if (name != "")
             builder.AppendWhereString(CustomerObject.NAME, name, QueryBuilder.ComparisonOperators.Like, QueryBuilder.ParameterLocation.FIRST);
         if (vat != "")
             builder.AppendWhereString(CustomerObject.VAT, vat, QueryBuilder.ComparisonOperators.Like, QueryBuilder.ParameterLocation.LAST);
         builder.AppendOrderBy(CustomerObject.NAME, QueryBuilder.OrderByType.ASC, QueryBuilder.ParameterLocation.FIRST_LAST);
         customers = CustomerConvertor.DataTableToCollection(this.ExecuteDataSet(builder.Query, false).Tables[0]);
     }
     catch (System.Exception exception1)
     {
         throw new Exception(MethodBase.GetCurrentMethod().Name, exception1);
     }
     return customers;
 }