public async Task DelayQueryOnSingletonNet45()
        {
            TestClientContext             = this.CreateWrappedContext <InMemoryEntities>().Context;
            TestClientContext.MergeOption = MergeOption.OverwriteChanges;

            var company = await TestClientContext.Company.GetValueAsync();

            Assert.IsNotNull(company);

            //LoadProperty
            await TestClientContext.LoadPropertyAsync(company, "Departments");

            Assert.IsNotNull(company.Departments);

            //Query Property
            var name = await TestClientContext.Company.Select(c => c.Name).GetValueAsync();

            Assert.AreEqual(company.Name, name);

            //Projection
            var companyQuery = TestClientContext.Company.Select(c => new Company()
            {
                Name = c.Name, Address = c.Address
            });
            var company2 = await companyQuery.GetValueAsync();

            Assert.IsTrue(companyQuery.RequestUri.OriginalString.EndsWith("/Company?$select=Name,Address"));
            Assert.IsNotNull(company2.Address);

            //Expand
            companyQuery = TestClientContext.Company.Expand(c => c.VipCustomer.Company);
            var company3 = await companyQuery.GetValueAsync();

            Assert.IsTrue(companyQuery.RequestUri.OriginalString.EndsWith("/Company?$expand=VipCustomer($expand=Company)"));
            Assert.IsNotNull(company);

            //Projection with Navigation
            companyQuery = TestClientContext.Company.Select(c => new Company()
            {
                Name = c.Name, Address = c.Address, Departments = c.Departments
            });
            await companyQuery.GetValueAsync();

            Assert.IsTrue(companyQuery.RequestUri.OriginalString.EndsWith("/Company?$expand=Departments&$select=Name,Address"));
            Assert.IsNotNull(company2.Address);

            //Query navigation property which is an collection
            var employeesQuery = TestClientContext.Company.Employees;
            var employees      = await employeesQuery.ExecuteAsync();

            Assert.IsTrue(employeesQuery.RequestUri.OriginalString.EndsWith("/Company/Employees"));
            Assert.IsNotNull(employees);

            //Query Navigation Property which is an single entity
            var company4Query = TestClientContext.Company.VipCustomer.Company;
            var company4      = await company4Query.GetValueAsync();

            Assert.IsTrue(company4Query.RequestUri.OriginalString.EndsWith("/Company/VipCustomer/Company"));
            Assert.IsNotNull(company4Query);

            //Query navigation property which is from a singleton
            var coreDepartmentQuery = TestClientContext.Company.CoreDepartment;
            var coreDepartment      = await coreDepartmentQuery.GetValueAsync();

            Assert.IsTrue(coreDepartmentQuery.RequestUri.OriginalString.EndsWith("/Company/CoreDepartment"));
            Assert.IsNotNull(coreDepartment);

            //QueryOption on navigation property
            employeesQuery = TestClientContext.Company.Employees.Where(e => e.PersonID > 0) as DataServiceQuery <Employee>;
            employees      = await employeesQuery.ExecuteAsync();

            Assert.IsTrue(employeesQuery.RequestUri.OriginalString.EndsWith("/Company/Employees?$filter=PersonID gt 0"));
            Assert.IsNotNull(employees);

            //Function Bound on Singleton
            var getEmployeesCountQuery = TestClientContext.Company.GetEmployeesCount();
            var count = await getEmployeesCountQuery.GetValueAsync();

            Assert.IsTrue(getEmployeesCountQuery.RequestUri.OriginalString.EndsWith("/Company/Microsoft.Test.OData.Services.ODataWCFService.GetEmployeesCount()"));
            Assert.IsTrue(count > 0);

            //Function Bound on Singleton
            var company5 = await TestClientContext.Company.GetValueAsync();

            getEmployeesCountQuery = company5.GetEmployeesCount();
            count = await getEmployeesCountQuery.GetValueAsync();

            Assert.IsTrue(getEmployeesCountQuery.RequestUri.OriginalString.EndsWith("/Company/Microsoft.Test.OData.Services.ODataWCFService.GetEmployeesCount()"));
            Assert.IsTrue(count > 0);

            //Query Action bound on Navigation Property, also on baseType
            var getHomeAddressQuery = TestClientContext.Company.VipCustomer.GetHomeAddress();
            var homeAddress         = await getHomeAddressQuery.GetValueAsync();

            Assert.IsTrue(getHomeAddressQuery.RequestUri.OriginalString.EndsWith("/Company/VipCustomer/Microsoft.Test.OData.Services.ODataWCFService.GetHomeAddress()"));
            Assert.IsNotNull(homeAddress);
        }
        public async Task DelayQueryOnSingletonNet45()
        {
            TestClientContext = this.CreateWrappedContext<InMemoryEntities>().Context;
            TestClientContext.MergeOption = MergeOption.OverwriteChanges;

            var company = await TestClientContext.Company.GetValueAsync();
            Assert.IsNotNull(company);

            //LoadProperty
            await TestClientContext.LoadPropertyAsync(company, "Departments");
            Assert.IsNotNull(company.Departments);

            //Query Property
            var name = await TestClientContext.Company.Select(c => c.Name).GetValueAsync();
            Assert.AreEqual(company.Name, name);

            //Projection
            var companyQuery = TestClientContext.Company.Select(c => new Company() { Name = c.Name, Address = c.Address });
            var company2 = await companyQuery.GetValueAsync();
            Assert.IsTrue(companyQuery.RequestUri.OriginalString.EndsWith("/Company?$select=Name,Address"));
            Assert.IsNotNull(company2.Address);

            //Expand
            companyQuery = TestClientContext.Company.Expand(c => c.VipCustomer.Company);
            var company3 = await companyQuery.GetValueAsync();
            Assert.IsTrue(companyQuery.RequestUri.OriginalString.EndsWith("/Company?$expand=VipCustomer($expand=Company)"));
            Assert.IsNotNull(company);

            //Projection with Navigation
            companyQuery = TestClientContext.Company.Select(c => new Company() { Name = c.Name, Address = c.Address, Departments = c.Departments });
            await companyQuery.GetValueAsync();
            Assert.IsTrue(companyQuery.RequestUri.OriginalString.EndsWith("/Company?$expand=Departments&$select=Name,Address"));
            Assert.IsNotNull(company2.Address);

            //Query navigation property which is an collection
            var employeesQuery = TestClientContext.Company.Employees;
            var employees = await employeesQuery.ExecuteAsync();
            Assert.IsTrue(employeesQuery.RequestUri.OriginalString.EndsWith("/Company/Employees"));
            Assert.IsNotNull(employees);

            //Query Navigation Property which is an single entity
            var company4Query = TestClientContext.Company.VipCustomer.Company;
            var company4 = await company4Query.GetValueAsync();
            Assert.IsTrue(company4Query.RequestUri.OriginalString.EndsWith("/Company/VipCustomer/Company"));
            Assert.IsNotNull(company4Query);

            //Query navigation property which is from a singleton
            var coreDepartmentQuery = TestClientContext.Company.CoreDepartment;
            var coreDepartment = await coreDepartmentQuery.GetValueAsync();
            Assert.IsTrue(coreDepartmentQuery.RequestUri.OriginalString.EndsWith("/Company/CoreDepartment"));
            Assert.IsNotNull(coreDepartment);

            //QueryOption on navigation property
            employeesQuery = TestClientContext.Company.Employees.Where(e => e.PersonID > 0) as DataServiceQuery<Employee>;
            employees = await employeesQuery.ExecuteAsync();
            Assert.IsTrue(employeesQuery.RequestUri.OriginalString.EndsWith("/Company/Employees?$filter=PersonID gt 0"));
            Assert.IsNotNull(employees);

            //Function Bound on Singleton
            var getEmployeesCountQuery = TestClientContext.Company.GetEmployeesCount();
            var count = await getEmployeesCountQuery.GetValueAsync();
            Assert.IsTrue(getEmployeesCountQuery.RequestUri.OriginalString.EndsWith("/Company/Microsoft.Test.OData.Services.ODataWCFService.GetEmployeesCount()"));
            Assert.IsTrue(count > 0);

            //Function Bound on Singleton
            var company5 = await TestClientContext.Company.GetValueAsync();
            getEmployeesCountQuery = company5.GetEmployeesCount();
            count = await getEmployeesCountQuery.GetValueAsync();
            Assert.IsTrue(getEmployeesCountQuery.RequestUri.OriginalString.EndsWith("/Company/Microsoft.Test.OData.Services.ODataWCFService.GetEmployeesCount()"));
            Assert.IsTrue(count > 0);

            //Query Action bound on Navigation Property, also on baseType
            var getHomeAddressQuery = TestClientContext.Company.VipCustomer.GetHomeAddress();
            var homeAddress = await getHomeAddressQuery.GetValueAsync();
            Assert.IsTrue(getHomeAddressQuery.RequestUri.OriginalString.EndsWith("/Company/VipCustomer/Microsoft.Test.OData.Services.ODataWCFService.GetHomeAddress()"));
            Assert.IsNotNull(homeAddress);
        }