public void Execute()
        {
            using (var dataContext = new FutureSimpleDataContext())
            {
                var people = dataContext.FuturePersons
                    .Where(a => a.FirstName == "Tom" || a.FirstName == "Cat")
                    .ToFuture();

                Assert.NotNull(people);
                Assert.False(people.IsValueCreated);
                Assert.Equal(1, dataContext.FutureCollection.Count);

                var pets = dataContext.FuturePets
                    .Where(a => a.Name == "Taboo")
                    .ToFuture();

                Assert.NotNull(pets);
                Assert.False(pets.IsValueCreated);
                Assert.Equal(2, dataContext.FutureCollection.Count);

                dataContext.FutureCollection.Execute();

                Assert.False(people.IsValueCreated);
                Assert.False(pets.IsValueCreated);
                Assert.Equal(0, dataContext.FutureCollection.Count);
            }
        }
Ejemplo n.º 2
0
        public void LotsOfParams()
        {
            using (var dataContext = new FutureSimpleDataContext())
            {
                var people = dataContext.FuturePersons
                    .Where(a => a.FirstName == "Tom" || a.FirstName == "Cat")
                    .ToFuture();

                Assert.NotNull(people);
                Assert.False(people.IsValueCreated);
                Assert.Equal(1, dataContext.FutureCollection.Count);

                var petIds = new List<int> { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };

                var pets = dataContext.FuturePets
                    .Where(p => petIds.Contains(p.Id))
                    .ToFuture();

                Assert.NotNull(pets);
                Assert.False(pets.IsValueCreated);
                Assert.Equal(2, dataContext.FutureCollection.Count);

                dataContext.FutureCollection.Execute();

                Assert.False(people.IsValueCreated);
                Assert.False(pets.IsValueCreated);
                Assert.Equal(0, dataContext.FutureCollection.Count);
            }
        }
Ejemplo n.º 3
0
 public void Example()
 {
     using (var dataContext = new FutureSimpleDataContext())
     using (dataContext.BeginTransaction())
     {
         // TODO: Stuff!
     }
 }
        public void NonDataQueryWithDataContext()
        {
            var list = new List<int> { 1, 2, 3 };
            var query = list.AsQueryable();

            using (var dataContext = new FutureSimpleDataContext())
            {
                var lazy = query.ToFuture(dataContext);

                Assert.NotNull(lazy);
                Assert.False(lazy.IsValueCreated);
                Assert.Equal(0, dataContext.FutureCollection.Count);

                var value = lazy.Value;

                Assert.NotNull(value);
                Assert.True(lazy.IsValueCreated);
                Assert.Equal(3, value.Count);
                Assert.Equal(0, dataContext.FutureCollection.Count);
            }
        }
        public void AddQuery()
        {
            using (var dataContext = new FutureSimpleDataContext())
            {
                var peopleQuery = dataContext.FuturePersons.Where(a => a.FirstName == "Tom" || a.FirstName == "Cat");
                var peopleFuture = dataContext.FutureCollection.Add(peopleQuery);
                var people = peopleFuture.ToLazy(dataContext.FutureCollection);

                Assert.NotNull(people);
                Assert.False(peopleFuture.IsValueLoaded);
                Assert.False(people.IsValueCreated);

                Assert.Equal(1, dataContext.FutureCollection.Count);

                var petsQuery = dataContext.FuturePets.Where(a => a.Name == "Taboo");
                var petsFuture = dataContext.FutureCollection.Add(petsQuery);
                var pets = petsFuture.ToLazy(dataContext.FutureCollection);

                Assert.NotNull(pets);
                Assert.False(petsFuture.IsValueLoaded);
                Assert.False(pets.IsValueCreated);

                Assert.Equal(2, dataContext.FutureCollection.Count);

                var petsValue = pets.Value;

                Assert.True(peopleFuture.IsValueLoaded);
                Assert.Equal(2, peopleFuture.Value.Count);
                Assert.False(people.IsValueCreated);

                Assert.True(petsFuture.IsValueLoaded);
                Assert.Equal(1, petsFuture.Value.Count);
                Assert.True(pets.IsValueCreated);
                Assert.Equal(1, petsValue.Count);

                Assert.Equal(0, dataContext.FutureCollection.Count);
            }
        }