public jsResponse <EmployeesCollection, Employees> Employees_LoadHierarchical()
        {
            jsResponse <EmployeesCollection, Employees> response = new jsResponse <EmployeesCollection, Employees>();

            try
            {
                // The Main Query
                EmployeesQuery q = new EmployeesQuery("e");
                q.Select(q.EmployeeID, q.FirstName, q.LastName, q.City, q.Country, q.HomePhone, q.Region, q.PostalCode, q.Title);
                q.Where(q.EmployeeID < 7);

                // The OrdersCollection
                OrdersQuery    o1   = q.Prefetch <OrdersQuery>(Employees.Prefetch_OrdersCollectionByEmployeeID);
                EmployeesQuery emp1 = o1.GetQuery <EmployeesQuery>();
                o1.Where(emp1.EmployeeID < 7);

                // The OrdersDetailsCollection
                OrderDetailsQuery od   = q.Prefetch <OrderDetailsQuery>(Employees.Prefetch_OrdersCollectionByEmployeeID, Orders.Prefetch_OrderDetailsCollectionByOrderID);
                EmployeesQuery    emp2 = od.GetQuery <EmployeesQuery>();
                OrdersQuery       o2   = od.GetQuery <OrdersQuery>();
                od.Where(emp2.EmployeeID < 7);

                // Load It
                EmployeesCollection coll = new EmployeesCollection();
                if (coll.Load(q))
                {
                    response.collection = coll;

                    response.columnCollection["Employees"]    = jsColumn.PopulateColumns(coll[0]);
                    response.columnCollection["Orders"]       = jsColumn.PopulateColumns(coll[0].OrdersCollectionByEmployeeID[0]);
                    response.columnCollection["OrderDetails"] = jsColumn.PopulateColumns(coll[0].OrdersCollectionByEmployeeID[0].OrderDetailsCollectionByOrderID[0]);
                }
            }
            catch (Exception ex)
            {
                response.exception = ex.Message;
            }

            return(response);
        }
        public EmployeesCollection Employees_PrefetchSophisticated()
        {
            // EmployeeID = "1"
            EmployeesCollection coll = new EmployeesCollection();

            coll.Query.Where(coll.Query.EmployeeID == 1);

            // Orders Query (nothing fancy, just ensure we're only getting Orders for EmployeeID = 1
            OrdersQuery    o  = coll.Query.Prefetch <OrdersQuery>(Employees.Prefetch_OrdersCollectionByEmployeeID);
            EmployeesQuery e1 = o.GetQuery <EmployeesQuery>();

            o.Where(e1.EmployeeID == 1);

            // OrderDetailsQuery (here we even limit the Select in addition to  EmployeeID = 1) notice the "false"
            OrderDetailsQuery od = coll.Query.Prefetch <OrderDetailsQuery>(false, Employees.Prefetch_OrdersCollectionByEmployeeID, Orders.Prefetch_OrderDetailsCollectionByOrderID);
            EmployeesQuery    e2 = od.GetQuery <EmployeesQuery>();

            od.Where(e2.EmployeeID == 1);
            od.Select(od.OrderID, od.ProductID, od.UnitPrice);

            coll.Query.Load();
            return(coll);
        }