Exemple #1
0
        public object Next()
        {
            if (current++ < aggregate.Count() - 1)
            {
                return(aggregate[current]);
            }

            return(null);
        }
Exemple #2
0
        public void CanSelectDistinctAggregationInGroupByUsingAggregateHelper()
        {
            var aggregations = Query <UserEntity>()
                               .Distinct()
                               .Select(u => new
            {
                Count = Aggregate.Count(u.Id),
                Role  = Aggregate.GroupBy(u.Role)
            });

            Assert.That(aggregations.Count(), Is.EqualTo(3));

            foreach (var a in aggregations)
            {
                switch (a.Role)
                {
                case RoleEnum.Administrator:
                    Assert.That(a.Count, Is.EqualTo(2));
                    break;

                default:
                    Assert.That(a.Count, Is.EqualTo(1));
                    break;
                }
            }
        }
        public IDataReader GetOrderCountByEtaMonth(Int32 companyid)
        {
            DateTime today     = DateTime.Today;
            DateTime _firstday = new DateTime(today.Year, today.Month, 1);
            DateTime _lastday  = _firstday.AddMonths(1).AddDays(-1);

            Aggregate _agr1 = Aggregate.GroupBy(OrderTable.EtaColumn);
            Aggregate _agr2 = Aggregate.Count(OrderTable.OrderIDColumn, "SumOrderID");

            Aggregate[]       _agrs = { _agr1, _agr2 };
            SubSonic.SqlQuery _qry  = new SubSonic.SqlQuery();

            if (companyid != -1) //restrict to specified company
            {
                _qry = new Select(_agrs).From(OrderTable.Schema).
                       Where(OrderTable.CompanyIDColumn).IsEqualTo(companyid).And(OrderTable.EtaColumn).IsBetweenAnd(_firstday, _lastday);
            }
            else
            {
                _qry = new Select(_agrs).From(OrderTable.Schema).
                       Where(OrderTable.EtaColumn).IsBetweenAnd(_firstday, _lastday);
            }

            IDataReader _rd = _qry.ExecuteReader();

            return(_rd);
        }
        public IDataReader GetOrderCountByEtaWeek(Int32 companyid)
        {
            System.Globalization.CultureInfo _ci = System.Threading.Thread.CurrentThread.CurrentCulture;
            System.DayOfWeek _fd = _ci.DateTimeFormat.FirstDayOfWeek;

            DateTime _firstday = DateTime.Today.AddDays(-(DateTime.Today.DayOfWeek - _fd));
            DateTime _lastday  = _firstday.AddDays(4); //monday to friday + 4

            Aggregate _agr1 = Aggregate.GroupBy(OrderTable.EtaColumn);
            Aggregate _agr2 = Aggregate.Count(OrderTable.OrderIDColumn, "SumOrderID");

            Aggregate[]       _agrs = { _agr1, _agr2 };
            SubSonic.SqlQuery _qry  = new SubSonic.SqlQuery();

            if (companyid != -1) //restrict to specified company
            {
                _qry = new Select(_agrs).From(OrderTable.Schema).
                       Where(OrderTable.CompanyIDColumn).IsEqualTo(companyid).And(OrderTable.EtaColumn).IsBetweenAnd(_firstday, _lastday);
            }
            else
            {
                _qry = new Select(_agrs).From(OrderTable.Schema).
                       Where(OrderTable.EtaColumn).IsBetweenAnd(_firstday, _lastday);
            }

            IDataReader _rd = _qry.ExecuteReader();

            return(_rd);
        }
        public void TestInferredGrouping()
        {
            var stuff = Query <UserEntity>()
                        .Select(x => new
            {
                Count = Aggregate.Count(x.Id),
                x.IsOnline
            })
                        .ToArray();

            Assert.That(stuff[0].Count, Is.GreaterThan(0));
            Assert.That(stuff[1].Count, Is.GreaterThan(0));
        }
        public void Aggregate_Count()
        {
            SubSonic.SqlQuery q = new Select(
                Aggregate.Count("ProductID"),
                Aggregate.Sum("UnitPrice", "boots"),
                Aggregate.GroupBy("categoryID"))
                                  .From("Products").Where("CategoryID").IsGreaterThan(5)
                                  .OrderAsc("categoryID").OrderDesc("boots");
            string sql = q.BuildSqlStatement();

            Assert.AreEqual(
                "SELECT COUNT(ProductID) AS 'CountOfProductID', SUM(UnitPrice) AS 'boots', categoryID AS 'GroupByOfcategoryID'\r\n FROM [dbo].[Products]\r\n WHERE [dbo].[Products].[CategoryID] > @CategoryID0\r\n GROUP BY categoryID\r\n ORDER BY categoryID ASC,boots DESC\r\n",
                sql);
        }
        public double GetOrderCountByEta(Int32 companyid, DateTime etadate)
        {
            double _ordercount = 0;

            if (companyid != -1)//restrict to specific comnpany
            {
                _ordercount = new Select(Aggregate.Count(OrderTable.OrderIDColumn, "SumOrderID")).From(OrderTable.Schema).
                              Where(OrderTable.CompanyIDColumn).IsEqualTo(companyid).And(OrderTable.EtaColumn).IsEqualTo(etadate.ToShortDateString()).ExecuteScalar <double>();
            }
            else
            {
                _ordercount = new Select(Aggregate.Count(OrderTable.OrderIDColumn, "SumOrderID")).From(OrderTable.Schema).
                              Where(OrderTable.EtaColumn).IsEqualTo(etadate.ToShortDateString()).ExecuteScalar <double>();
            }
            return(_ordercount);
        }
        public int GetOrderCountByUserId(Int32 userid, DateTime mindate, DateTime maxdate)
        {
            int _ordercount = 0;

            if (userid > 0)
            {
                _ordercount = new Select(Aggregate.Count(OrderTable.OrderIDColumn, "SumOrderID")).From(OrderTable.Schema).
                              Where(OrderTable.DateOrderCreatedColumn).IsBetweenAnd(mindate, maxdate).And(OrderTable.OrderControllerIDColumn).IsEqualTo(userid).And(OrderTable.JobClosedColumn).IsEqualTo(false).
                              Or(OrderTable.DateOrderCreatedColumn).IsBetweenAnd(mindate, maxdate).And(OrderTable.OrderControllerIDColumn).IsEqualTo(userid).And(OrderTable.JobClosedColumn).IsEqualTo(false).
                              Or(OrderTable.DateOrderCreatedColumn).IsBetweenAnd(mindate, maxdate).And(OrderTable.OriginPortControllerIDColumn).IsEqualTo(userid).And(OrderTable.JobClosedColumn).IsEqualTo(false).
                              Or(OrderTable.DateOrderCreatedColumn).IsBetweenAnd(mindate, maxdate).And(OrderTable.DestinationPortControllerIDColumn).IsEqualTo(userid).And(OrderTable.JobClosedColumn).IsEqualTo(false).
                              ExecuteScalar <int>();
            }

            return(_ordercount);
        }
        public void CanSelectAggregationInGroupByUsingAggregateHelper()
        {
            var aggregations = Query <UserEntity>()
                               .Select(u => new
            {
                Count = Aggregate.Count(u.Id),
                Role  = Aggregate.GroupBy(u.Role)
            });

            Assert.That(aggregations.Count(), Is.EqualTo(3));

            foreach (var a in aggregations)
            {
                if (a.Role == RoleEnum.Administrator)
                {
                    Assert.That(a.Count, Is.EqualTo(2));
                }
                else
                {
                    Assert.That(a.Count, Is.EqualTo(1));
                }
            }
        }
        public void CanSelectAggregationUsingAggregateHelper()
        {
            var aggregation = Query <UserEntity>()
                              .Select(u => new
            {
                Avg = Aggregate.Average(u.Id),
                Sum = Aggregate.Sum(u.Id),
                Min = Aggregate.Min(u.Id),
                Max = Aggregate.Max(u.Id),
                Cnt = Aggregate.Count(u.Id),
                Cnd = Aggregate.CountDistinct(u.Id)
            });

            Assert.That(aggregation.Count(), Is.EqualTo(1));

            var a = aggregation.First();

            Assert.That(a.Avg, Is.EqualTo(2.5));
            Assert.That(a.Sum, Is.EqualTo(10));
            Assert.That(a.Min, Is.EqualTo(1));
            Assert.That(a.Max, Is.EqualTo(4));
            Assert.That(a.Cnt, Is.EqualTo(4));
            Assert.That(a.Cnd, Is.EqualTo(4));
        }
 public void CountThrowsWhenCalledOutsideLambdaExpression()
 {
     Assert.That(() => Aggregate.Count(3), Throws.InstanceOf <InvalidOperationException>());
     Assert.That(() => Aggregate.Count((int?)3), Throws.InstanceOf <InvalidOperationException>());
 }
Exemple #12
0
    //end eta charts

    protected void bind_metrics()
    {
        string         _contactid   = ((UserClass)Page.Session["user"]).UserId.ToString();
        IList <string> _deliveryids = null;

        _deliveryids = wwi_func.array_from_xml("xml\\contact_iso.xml", "contactlist/contact[id='" + _contactid + "']/deliveryids/deliveryid/value");
        if (_deliveryids.Count == 0)
        {
            string _companyid = ((UserClass)Page.Session["user"]).CompanyId.ToString();
            _deliveryids.Add(_companyid);
        }

        //object[] _in = { 406, 12346, 13776 };
        DateTime _dx = DateTime.Now.AddMonths(-1);

        DataTable _dt = new Select(Aggregate.Count(DAL.Logistics.ContainerTable.ContainerIDColumn),
                                   Aggregate.Avg(DAL.Logistics.OrderTable.NumberOfPackagesColumn),
                                   Aggregate.Min(DAL.Logistics.OrderTable.NumberOfPackagesColumn),
                                   Aggregate.Max(DAL.Logistics.OrderTable.NumberOfPackagesColumn),
                                   Aggregate.GroupBy(DAL.Logistics.OrderTable.EtsColumn))
                        .From(DAL.Logistics.Tables.DeliverySubTable)
                        .InnerJoin(DAL.Logistics.ContainerSubTable.OrderNumberColumn, DAL.Logistics.DeliverySubTable.OrderNumberColumn)
                        .InnerJoin(DAL.Logistics.ContainerTable.ContainerIDColumn, DAL.Logistics.ContainerSubTable.ContainerIDColumn)
                        .InnerJoin(DAL.Logistics.OrderTable.OrderIDColumn, DAL.Logistics.ContainerSubTable.OrderIDColumn)
                        .InnerJoin(DAL.Logistics.NameAndAddressBook.CompanyIDColumn, DAL.Logistics.OrderTable.CompanyIDColumn)
                        .Where(DAL.Logistics.DeliverySubTable.DeliveryAddressColumn).In(_deliveryids).And(DAL.Logistics.OrderTable.EtsColumn).IsGreaterThanOrEqualTo(_dx)
                        .ExecuteDataSet().Tables[0];

        Series _s = this.dxchartMetrics.Series["Lowest"]; //define series

        _s.DataSource = _dt;
        //columns
        _s.ArgumentScaleType  = ScaleType.Qualitative;
        _s.ArgumentDataMember = "GroupByOfETS";

        XYDiagram _xy = (XYDiagram)this.dxchartMetrics.Diagram;

        this.dxchartMetrics.Legend.Visible = true;
        //stagger x axis lables
        _xy.AxisX.Label.Staggered = false;
        //rotate them.
        _xy.AxisX.Label.Angle        = -30;
        _xy.AxisX.Label.Antialiasing = true;
        //rows
        _s.ValueScaleType = ScaleType.Numerical;
        _s.ValueDataMembers.AddRange(new string[] { "MinOfNumberOfPackages" });

        _s            = this.dxchartMetrics.Series["Average"]; //define series
        _s.DataSource = _dt;
        //columns
        _s.ArgumentScaleType  = ScaleType.Qualitative;
        _s.ArgumentDataMember = "GroupByOfETS";
        //rows
        _s.ValueScaleType = ScaleType.Numerical;
        _s.ValueDataMembers.AddRange(new string[] { "AvgOfNumberOfPackages" });

        _s            = this.dxchartMetrics.Series["Highest"]; //define series
        _s.DataSource = _dt;
        //columns
        _s.ArgumentScaleType  = ScaleType.Qualitative;
        _s.ArgumentDataMember = "GroupByOfETS";
        //rows
        _s.ValueScaleType = ScaleType.Numerical;
        _s.ValueDataMembers.AddRange(new string[] { "MaxOfNumberOfPackages" });

        this.dxchartMetrics.DataBind();
    }
Exemple #13
0
    //end ets charts
    protected void bind_all_eta_charts(string datetype, int daterange)
    {
        //if (e.Parameter == "getdata" && Page.Session["shippingloaded"] == null)
        //{
        Page.Session["shippingloaded"] = true;

        string         _contactid   = ((UserClass)Page.Session["user"]).UserId.ToString();
        IList <string> _deliveryids = null;

        _deliveryids = wwi_func.array_from_xml("xml\\contact_iso.xml", "contactlist/contact[id='" + _contactid + "']/deliveryids/deliveryid/value");
        if (_deliveryids.Count == 0)
        {
            string _companyid = ((UserClass)Page.Session["user"]).CompanyId.ToString();
            _deliveryids.Add(_companyid);
        }

        //object[] _in = { 406, 12346, 13776 };
        DateTime _dx = DateTime.MinValue;

        if (datetype == "days")
        {
            _dx = DateTime.Now.AddDays(daterange);
        }
        else
        {
            _dx = DateTime.Now.AddMonths(daterange);
        }

        DataTable _dt = new Select(Aggregate.Count(DAL.Logistics.ContainerTable.ContainerIDColumn),
                                   Aggregate.Sum(DAL.Logistics.ContainerSubTable.WeightColumn),
                                   Aggregate.Sum(DAL.Logistics.ContainerSubTable.CbmColumn),
                                   Aggregate.Sum(DAL.Logistics.OrderTable.NumberOfPackagesColumn),
                                   Aggregate.GroupBy(DAL.Logistics.NameAndAddressBook.CompanyNameColumn))
                        .From(DAL.Logistics.Tables.DeliverySubTable)
                        .InnerJoin(DAL.Logistics.ContainerSubTable.OrderNumberColumn, DAL.Logistics.DeliverySubTable.OrderNumberColumn)
                        .InnerJoin(DAL.Logistics.ContainerTable.ContainerIDColumn, DAL.Logistics.ContainerSubTable.ContainerIDColumn)
                        .InnerJoin(DAL.Logistics.OrderTable.OrderIDColumn, DAL.Logistics.ContainerSubTable.OrderIDColumn)
                        .InnerJoin(DAL.Logistics.NameAndAddressBook.CompanyIDColumn, DAL.Logistics.OrderTable.CompanyIDColumn)
                        .Where(DAL.Logistics.DeliverySubTable.DeliveryAddressColumn).In(_deliveryids).And(DAL.Logistics.OrderTable.EtaColumn).IsGreaterThanOrEqualTo(_dx)
                        .ExecuteDataSet().Tables[0];

        Series _s = this.dxchartPalletsWeightWW.Series["Pallets"]; //containers

        _s.DataSource = _dt;
        //columns
        _s.ArgumentScaleType  = ScaleType.Qualitative;
        _s.ArgumentDataMember = "GroupByOfCompanyName";

        XYDiagram _xy = (XYDiagram)this.dxchartPalletsWeightWW.Diagram;

        this.dxchartPalletsWeightWW.Legend.Visible = true;
        //stagger x axis lables
        _xy.AxisX.Label.Staggered = false;
        //rotate them.
        _xy.AxisX.Label.Angle        = -30;
        _xy.AxisX.Label.Antialiasing = true;
        //rows
        _s.ValueScaleType = ScaleType.Numerical;
        _s.ValueDataMembers.AddRange(new string[] { "SumOfNumberOfPackages" });

        _s            = this.dxchartPalletsWeightWW.Series["Weight"]; //containers
        _s.DataSource = _dt;

        //columns
        _s.ArgumentScaleType  = ScaleType.Qualitative;
        _s.ArgumentDataMember = "GroupByOfCompanyName";
        //rows
        _s.ValueScaleType = ScaleType.Numerical;
        _s.ValueDataMembers.AddRange(new string[] { "SumOfWeight" });
        this.dxchartPalletsWeightWW.DataBind();

        //******************
        _s = this.dxchartContainersWW.Series["Containers"]; //containers

        _s.Label.TextOrientation      = TextOrientation.Horizontal;
        _s.DataSource                 = _dt;
        _s.LegendPointOptions.Pattern = "{A}";
        //_s.PointOptions.Pattern = "{A}: {V:F1}";

        //columns
        _s.ArgumentScaleType  = ScaleType.Qualitative;
        _s.ArgumentDataMember = "GroupByOfCompanyName"; //GroupByOfCompanyName
        //rows
        _s.ValueScaleType = ScaleType.Numerical;
        _s.ValueDataMembers.AddRange(new string[] { "CountOfContainerID" }); //PcOfContainerID
        this.dxchartContainersWW.DataBind();
    }
Exemple #14
0
    //protected void dxchartShipping_CustomCallback(object sender, DevExpress.XtraCharts.Web.CustomCallbackEventArgs e)
    protected void bind_all_ets_charts(string datetype, int daterange)
    {
        //if (e.Parameter == "getdata" && Page.Session["shippingloaded"] == null)
        //{
        string         _contactid   = ((UserClass)Page.Session["user"]).UserId.ToString();
        IList <string> _deliveryids = null;

        _deliveryids = wwi_func.array_from_xml("xml\\contact_iso.xml", "contactlist/contact[id='" + _contactid + "']/deliveryids/deliveryid/value");
        if (_deliveryids.Count == 0)
        {
            string _companyid = ((UserClass)Page.Session["user"]).CompanyId.ToString();
            _deliveryids.Add(_companyid);
        }

        //object[] _in = { 406, 12346, 13776 };
        DateTime _dx = DateTime.MinValue;

        if (datetype == "days")
        {
            _dx = DateTime.Now.AddDays(daterange);
        }
        else
        {
            _dx = DateTime.Now.AddMonths(daterange);
        }

        DataTable _dt = new Select(Aggregate.Count(DAL.Logistics.ContainerTable.ContainerIDColumn),
                                   Aggregate.Sum(DAL.Logistics.ContainerSubTable.WeightColumn),
                                   Aggregate.Sum(DAL.Logistics.ContainerSubTable.CbmColumn),
                                   Aggregate.Sum(DAL.Logistics.OrderTable.NumberOfPackagesColumn),
                                   Aggregate.GroupBy(DAL.Logistics.NameAndAddressBook.CompanyNameColumn))
                        .From(DAL.Logistics.Tables.DeliverySubTable)
                        .InnerJoin(DAL.Logistics.ContainerSubTable.OrderNumberColumn, DAL.Logistics.DeliverySubTable.OrderNumberColumn)
                        .InnerJoin(DAL.Logistics.ContainerTable.ContainerIDColumn, DAL.Logistics.ContainerSubTable.ContainerIDColumn)
                        .InnerJoin(DAL.Logistics.OrderTable.OrderIDColumn, DAL.Logistics.ContainerSubTable.OrderIDColumn)
                        .InnerJoin(DAL.Logistics.NameAndAddressBook.CompanyIDColumn, DAL.Logistics.OrderTable.CompanyIDColumn)
                        .Where(DAL.Logistics.DeliverySubTable.DeliveryAddressColumn).In(_deliveryids).And(DAL.Logistics.OrderTable.EtsColumn).IsGreaterThanOrEqualTo(_dx)
                        .ExecuteDataSet().Tables[0];

        //bind bar chart serices for containers ETS this week
        ////this.dxchartShipping.DataSource = _dt;
        //this.dxchartShipping.Series.Add("Containers", ViewType.Bar);
        //Series _s = this.dxchartShipping.Series["Containers"]; //containers
        //_s.Label.TextOrientation = TextOrientation.Horizontal;
        //_s.DataSource = _dt;
        //columns
        //_s.ArgumentScaleType = ScaleType.Qualitative;
        //_s.ArgumentDataMember = "GroupByOfCompanyName";
        //rows
        //_s.ValueScaleType = ScaleType.Numerical;
        //_s.ValueDataMembers.AddRange(new string[] { "CountOfContainerID" });
        if (datetype == "days")
        {
            Series _s = this.dxchartPalletsWeightWW.Series["Pallets"]; //containers
            _s.DataSource = _dt;

            //columns
            _s.ArgumentScaleType  = ScaleType.Qualitative;
            _s.ArgumentDataMember = "GroupByOfCompanyName";

            XYDiagram _xy = (XYDiagram)this.dxchartPalletsMM.Diagram;
            this.dxchartPalletsWeightWW.Legend.Visible = true;
            //stagger x axis lables
            _xy.AxisX.Label.Staggered = true;
            //rotate them.
            _xy.AxisX.Label.Angle        = 45;
            _xy.AxisX.Label.Antialiasing = true;
            //rows
            _s.ValueScaleType = ScaleType.Numerical;
            _s.ValueDataMembers.AddRange(new string[] { "SumOfNumberOfPackages" });

            _s            = this.dxchartPalletsWeightWW.Series["Weight"]; //containers
            _s.DataSource = _dt;

            //columns
            _s.ArgumentScaleType  = ScaleType.Qualitative;
            _s.ArgumentDataMember = "GroupByOfCompanyName";
            //rows
            _s.ValueScaleType = ScaleType.Numerical;
            _s.ValueDataMembers.AddRange(new string[] { "SumOfWeight" });
            this.dxchartPalletsWeightWW.DataBind();
        }
        else
        {
            //bind bar chart series for pallets ETS this week
            //this.dxchartPalletsMM.Series.Add("Pallets", ViewType.Bar); defined in properties
            Series _s = this.dxchartPalletsMM.Series["Pallets"]; //define series
            _s.DataSource = _dt;
            //columns
            _s.ArgumentScaleType  = ScaleType.Qualitative;
            _s.ArgumentDataMember = "GroupByOfCompanyName";

            XYDiagram _xy = (XYDiagram)this.dxchartPalletsMM.Diagram;
            this.dxchartPalletsMM.Legend.Visible = true;
            //stagger x axis lables
            _xy.AxisX.Label.Staggered = false;
            //rotate them.
            _xy.AxisX.Label.Angle        = -30;
            _xy.AxisX.Label.Antialiasing = true;

            //rows
            _s.ValueScaleType = ScaleType.Numerical;
            _s.ValueDataMembers.AddRange(new string[] { "SumOfNumberOfPackages" });

            //bind bar chart series for cube ETS this week
            //this.dxchartPalletsMM.Series.Add("Cube", ViewType.Bar);
            //_s = this.dxchartPalletsMM.Series["Cube"]; //containers
            //_s.DataSource = _dt;

            //columns
            //_s.ArgumentScaleType = ScaleType.Qualitative;
            //_s.ArgumentDataMember = "GroupByOfCompanyName";
            //rows
            //_s.ValueScaleType = ScaleType.Numerical;
            //_s.ValueDataMembers.AddRange(new string[] { "SumOfCbm" });
            //this.dxchartPalletsMM.DataBind();
            //***************
            //bind bar chart series for cube ETS this week
            //this.dxchartCubeMM.Series.Add("Cube", ViewType.Bar);
            _s            = this.dxchartCubeMM.Series["Cube"]; //containers
            _s.DataSource = _dt;

            //columns
            _s.ArgumentScaleType  = ScaleType.Qualitative;
            _s.ArgumentDataMember = "GroupByOfCompanyName";

            _xy = (XYDiagram)this.dxchartCubeMM.Diagram;
            this.dxchartCubeMM.Legend.Visible = true;
            //stagger x axis lables
            _xy.AxisX.Label.Staggered = false;
            //rotate them.
            _xy.AxisX.Label.Angle        = -30;
            _xy.AxisX.Label.Antialiasing = true;
            //rows
            _s.ValueScaleType = ScaleType.Numerical;
            _s.ValueDataMembers.AddRange(new string[] { "SumOfCbm" });
            this.dxchartCubeMM.DataBind();

            //***************
            //bind bar chart series for weight ETS this week (seperate from chartShipping as likely to be much higher numbers)
            //this.dxchartWeight.DataSource = _dt;

            //this.dxchartWeightMM.Series.Add("Weight", ViewType.Bar);
            _s = this.dxchartWeightMM.Series["Weight"]; //containers

            _xy = (XYDiagram)this.dxchartWeightMM.Diagram;

            this.dxchartPalletsMM.Legend.Visible = true;
            //stagger x axis lables
            _xy.AxisX.Label.Staggered = false;
            //rotate them.
            _xy.AxisX.Label.Angle        = -30;
            _xy.AxisX.Label.Antialiasing = true;

            _s.Label.TextOrientation = TextOrientation.Horizontal;
            _s.DataSource            = _dt;

            //columns
            _s.ArgumentScaleType  = ScaleType.Qualitative;
            _s.ArgumentDataMember = "GroupByOfCompanyName";
            //rows
            _s.ValueScaleType = ScaleType.Numerical;
            _s.ValueDataMembers.AddRange(new string[] { "SumOfWeight" });
            this.dxchartWeightMM.DataBind();

            //***************
            //pie chart deliveries by client
            //total containers
            //double _containers = wwi_func.vdouble(_dt.Compute("Sum(CountOfContainerID)", "CountOfContainerID >=0").ToString());
            //_dt.Columns.Add(new DataColumn("PcOfContainerID", typeof(double)));

            //for(int _ix =0; _ix < _dt.Rows.Count; _ix++)
            //{
            //_dt.Rows[_ix]["PcOfContainerID"] = (_containers / 100) * wwi_func.vdouble(_dt.Rows[_ix]["CountOfContainerID"].ToString());
            //}

            //this.dxchartContainersMM.Series.Add("Containers", ViewType.Pie);
            _s = this.dxchartContainersMM.Series["Containers"]; //containers

            //_xy = (XYDiagram)this.dxchartWeight.Diagram;

            //this.dxchartShipping.Legend.Visible = false;
            //stagger x axis lables
            //_xy.AxisX.Label.Staggered = false;
            //rotate them.
            //_xy.AxisX.Label.Angle = -30;
            //_xy.AxisX.Label.Antialiasing = true;

            _s.Label.TextOrientation      = TextOrientation.Horizontal;
            _s.DataSource                 = _dt;
            _s.LegendPointOptions.Pattern = "{A}";
            //_s.PointOptions.Pattern = "{A}: {V:F1}";

            //columns
            _s.ArgumentScaleType  = ScaleType.Qualitative;
            _s.ArgumentDataMember = "GroupByOfCompanyName"; //GroupByOfCompanyName
            //rows
            _s.ValueScaleType = ScaleType.Numerical;
            _s.ValueDataMembers.AddRange(new string[] { "CountOfContainerID" }); //PcOfContainerID
            this.dxchartContainersMM.DataBind();
        }
        //}
    }
        public void CanSelectAggregationUsingAggregateHelper()
        {
            // avg
            IDetachedFlowQuery <UserEntity> aggregation = DetachedQuery <UserEntity>()
                                                          .Select(u => Aggregate.Average(u.Id));

            IEnumerable <UserEntity> users = Query <UserEntity>()
                                             .Where(x => x.Id, FqIs.GreaterThan(aggregation))
                                             .Select();

            Assert.That(users.Count(), Is.EqualTo(2));

            // sum
            aggregation = DetachedQuery <UserEntity>()
                          .Select(u => Aggregate.Sum(u.Id));

            users = Query <UserEntity>()
                    .Where(x => x.Id, FqIs.LessThan(aggregation))
                    .Select();

            Assert.That(users.Count(), Is.EqualTo(4));

            // min
            aggregation = DetachedQuery <UserEntity>()
                          .Select(u => Aggregate.Min(u.Id));

            users = Query <UserEntity>()
                    .Where(x => x.Id, FqIs.EqualTo(aggregation))
                    .Select();

            Assert.That(users.Count(), Is.EqualTo(1));
            Assert.That(users.First().Id, Is.EqualTo(1));

            // max
            aggregation = DetachedQuery <UserEntity>()
                          .Select(u => Aggregate.Max(u.Id));

            users = Query <UserEntity>()
                    .Where(x => x.Id, FqIs.EqualTo(aggregation))
                    .Select();

            Assert.That(users.Count(), Is.EqualTo(1));
            Assert.That(users.First().Id, Is.EqualTo(4));

            // count
            aggregation = DetachedQuery <UserEntity>()
                          .Select(u => Aggregate.Count(u.Id));

            users = Query <UserEntity>()
                    .Where(x => x.Id, FqIs.EqualTo(aggregation))
                    .Select();

            Assert.That(users.Count(), Is.EqualTo(1));
            Assert.That(users.First().Id, Is.EqualTo(4));

            // count distinct
            aggregation = DetachedQuery <UserEntity>()
                          .Select(u => Aggregate.CountDistinct(u.Id));

            users = Query <UserEntity>()
                    .Where(x => x.Id, FqIs.EqualTo(aggregation))
                    .Select();

            Assert.That(users.Count(), Is.EqualTo(1));
            Assert.That(users.First().Id, Is.EqualTo(4));

            // group by
            aggregation = DetachedQuery <UserEntity>()
                          .Select(x => Aggregate.GroupBy(x.Id));

            users = Query <UserEntity>()
                    .Where(x => x.Id, FqIs.In(aggregation))
                    .Select();

            Assert.That(users.Count(), Is.EqualTo(4));
        }