private static void QueryEntityInstanceBatchAsync(DataServiceContextWrapper <DefaultContainer> contextWrapper)
        {
            contextWrapper.Context.IgnoreMissingProperties = true;

            contextWrapper.Configurations.ResponsePipeline
            .OnEntryEnded(PipelineEventsTestsHelper.AddRemovePropertySpecialEmployeeEntry_Reading)
            .OnEntityMaterialized(PipelineEventsTestsHelper.AddEnumPropertySpecialEmployeeEntity_Materialized)
            .OnEntityMaterialized(PipelineEventsTestsHelper.ModifyPropertyValueCustomerEntity_Materialized);

            DataServiceRequest[] requests = new DataServiceRequest[]
            {
                contextWrapper.CreateQuery <Person>("Person(-10)"),
                contextWrapper.CreateQuery <Customer>("Customer"),
            };

            DataServiceResponse responses = null;
            IAsyncResult        r         = contextWrapper.BeginExecuteBatch(
                result => { responses = contextWrapper.EndExecuteBatch(result); },
                null,
                requests);

            while (!r.IsCompleted)
            {
                Thread.Sleep(1000);
            }

            bool personVerified   = false;
            bool customerVerified = false;

            foreach (QueryOperationResponse response in responses)
            {
                foreach (object p in response)
                {
                    SpecialEmployee se1 = p as SpecialEmployee;
                    Customer        c   = p as Customer;
                    if (se1 != null)
                    {
                        Assert.AreEqual("AddRemovePropertySpecialEmployeeEntry_Reading", se1.CarsLicensePlate,
                                        "Unexpected CarsLicensePlate");
                        Assert.AreEqual(1, se1.BonusLevel, "Unexpected BonusLevel");
                        personVerified = true;
                    }

                    if (c != null)
                    {
                        Assert.IsTrue(c.Name.EndsWith("ModifyPropertyValueCustomerEntity_Materialized"),
                                      "Unexpected primitive property");
                        Assert.IsTrue(c.Auditing.ModifiedBy.Equals("ModifyPropertyValueCustomerEntity_Materialized"),
                                      "Unexpected complex property");
                        Assert.IsTrue(c.PrimaryContactInfo.EmailBag.Contains("ModifyPropertyValueCustomerEntity_Materialized"),
                                      "Unexpected collection property");
                        customerVerified = true;
                    }
                }
            }

            Assert.IsTrue(personVerified && customerVerified, "Some inner request does not completed correctly");
        }
        private static void QueryEntityInstanceBatchAsync(DataServiceContextWrapper<DefaultContainer> contextWrapper)
        {
            contextWrapper.Context.IgnoreMissingProperties = true;

            contextWrapper.Configurations.ResponsePipeline
                .OnEntryEnded(PipelineEventsTestsHelper.AddRemovePropertySpecialEmployeeEntry_Reading)
                .OnEntityMaterialized(PipelineEventsTestsHelper.AddEnumPropertySpecialEmployeeEntity_Materialized)
                .OnEntityMaterialized(PipelineEventsTestsHelper.ModifyPropertyValueCustomerEntity_Materialized);

            DataServiceRequest[] requests = new DataServiceRequest[]
            {
                contextWrapper.CreateQuery<Person>("Person(-10)"),
                contextWrapper.CreateQuery<Customer>("Customer"),
            };

            DataServiceResponse responses = null;
            IAsyncResult r = contextWrapper.BeginExecuteBatch(
                result => { responses = contextWrapper.EndExecuteBatch(result); },
                null,
                requests);

            while (!r.IsCompleted)
            {
                Thread.Sleep(1000);
            }

            bool personVerified = false;
            bool customerVerified = false;
            foreach (QueryOperationResponse response in responses)
            {
                foreach (object p in response)
                {
                    SpecialEmployee se1 = p as SpecialEmployee;
                    Customer c = p as Customer;
                    if (se1 != null)
                    {
                        Assert.AreEqual("AddRemovePropertySpecialEmployeeEntry_Reading", se1.CarsLicensePlate,
                            "Unexpected CarsLicensePlate");
                        Assert.AreEqual(1, se1.BonusLevel, "Unexpected BonusLevel");
                        personVerified = true;
                    }

                    if (c != null)
                    {
                        Assert.IsTrue(c.Name.EndsWith("ModifyPropertyValueCustomerEntity_Materialized"),
                            "Unexpected primitive property");
                        Assert.IsTrue(c.Auditing.ModifiedBy.Equals("ModifyPropertyValueCustomerEntity_Materialized"),
                            "Unexpected complex property");
                        Assert.IsTrue(c.PrimaryContactInfo.EmailBag.Contains("ModifyPropertyValueCustomerEntity_Materialized"),
                            "Unexpected collection property");
                        customerVerified = true;
                    }
                }
            }

            Assert.IsTrue(personVerified && customerVerified, "Some inner request does not completed correctly");
        }