Esempio n. 1
0
        public void Non_generic_AsStreaming_can_be_used_directly_on_DbQuery()
        {
            try
            {
                ProviderAgnosticConfiguration.SuspendExecutionStrategy = true;
                using (var context = new ProviderAgnosticContext())
                {
                    var expression = context.Gears.Where(g => g.Rank > MilitaryRank.Private).Expression;
                    var query      = (DbQuery)((IQueryable)context.Set(typeof(Gear))).Provider.CreateQuery(expression);
                    var count      = 0;
                    foreach (var result in query)
                    {
                        Assert.NotNull(result);
                        Assert.True(context.Database.Connection.State == ConnectionState.Open);
                        count++;
                    }

                    Assert.Equal(3, count);

                    count = 0;
                    foreach (var gear in query.AsStreaming())
                    {
                        Assert.NotNull(gear);
                        Assert.True(context.Database.Connection.State == ConnectionState.Open);
                        count++;
                    }

                    Assert.Equal(3, count);
                }
            }
            finally
            {
                ProviderAgnosticConfiguration.SuspendExecutionStrategy = false;
            }
        }
Esempio n. 2
0
        public void Non_generic_AsStreaming_can_be_used_directly_on_DbSet()
        {
            try
            {
                ProviderAgnosticConfiguration.SuspendExecutionStrategy = true;
                using (var context = new ProviderAgnosticContext())
                {
                    var gears = context.Set(typeof(Gear));

                    var count = 0;
                    foreach (var gear in gears)
                    {
                        Assert.NotNull(gear);
                        Assert.True(context.Database.Connection.State == ConnectionState.Open);
                        count++;
                    }

                    Assert.Equal(5, count);

                    count = 0;
                    foreach (var gear in gears.AsStreaming())
                    {
                        Assert.NotNull(gear);
                        Assert.True(context.Database.Connection.State == ConnectionState.Open);
                        count++;
                    }

                    Assert.Equal(5, count);
                }
            }
            finally
            {
                ProviderAgnosticConfiguration.SuspendExecutionStrategy = false;
            }
        }