[This is preliminary documentation and is subject to change.]

Represents a definition of how to sort rows

Namespace:  Firefly.Box
Assembly:  Firefly.Box (in Firefly.Box.dll) Version: 3.4.23.6473 (3.4.23.6473)

Syntax

C#
public class Sort
Visual Basic (Declaration)
Public Class Sort
Visual C++
public ref class Sort

Examples

This example demonstrates the usage of DemoOrderBy
This example is in the form of Unit Tests. It references the NUnit framework. This framework can be downloaded from www.NUnit.org. For more information about unit testing visit: www.NUnit.org.
This example is based on test data. The code for the entities included in this test data can be found in the documentation of Entity
CopyC#
using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using Firefly.Box;
using Firefly.Box.Testing;

namespace TestFirefly.Box.Documentation
{
    [TestFixture]
    public class DemoOrderBy
    {
        [Test]
        public void UsingDefaultInstance()
        {
            var jobs = new Pubs.Jobs();
            jobs.InitializeWithTestData();

            var bp = new BusinessProcess
                         {
                             From = jobs,
                         };
            bp.Where.Add(jobs.Id.IsLessOrEqualTo(5));
            bp.OrderBy.Segments.Add(jobs.Id, SortDirection.Descending);

            string result = "";
            bp.ForEachRow(() =>
                              {
                                  result += jobs.Id + "\n";
                              });
            result.ShouldBe(" 5\n" +
                            " 4\n" +
                            " 3\n" +
                            " 2\n" +
                            " 1\n");
        }
        [Test]
        public void UsingNewInstance()
        {
            var jobs = new Pubs.Jobs();
            jobs.InitializeWithTestData();

            var bp = new BusinessProcess
            {
                From = jobs,
            };
            bp.Where.Add(jobs.Id.IsLessOrEqualTo(5));
            var sort = new Sort();
            sort.Segments.Add(jobs.MinLevel);
            sort.Segments.Add(jobs.Id, SortDirection.Descending);

            bp.OrderBy = sort;
            string result = "";
            bp.ForEachRow(() =>
            {
                result += jobs.Id + " - " + jobs.MinLevel + "\n";
            });
            result.ShouldBe(" 1 -  10\n" +
                            " 5 - 150\n" +
                            " 4 - 175\n" +
                            " 3 - 175\n" +
                            " 2 - 200\n");
        }
        [Test]
        public void ReverseRowOrder()
        {
            var jobs = new Pubs.Jobs();
            jobs.InitializeWithTestData();

            var bp = new BusinessProcess
            {
                From = jobs,
            };
            bp.Where.Add(jobs.Id.IsLessOrEqualTo(5));

            bp.OrderBy.Segments.Add(jobs.MinLevel);
            bp.OrderBy.Segments.Add(jobs.Id, SortDirection.Descending);
            bp.OrderBy.Reversed = true;

            string result = "";
            bp.ForEachRow(() =>
            {
                result += jobs.Id + " - " + jobs.MinLevel + "\n";
            });
            result.ShouldBe(" 2 - 200\n" +
                            " 3 - 175\n" +
                            " 4 - 175\n" +
                            " 5 - 150\n" +
                            " 1 -  10\n");
        }
    }
}

Inheritance Hierarchy

System..::.Object
  Firefly.Box..::.Sort

See Also