Example #1
0
        public override Guestbook GetById(int id)
        {
            var spec = new GuestbookWithEntriesSpec();

            return(_dbContext.Guestbooks
                   .Include(spec.Include)
                   .FirstOrDefault(g => g.Id == id));
        }
Example #2
0
        public void IncludeRelatedEntries()
        {
            // add data
            var    repository = GetRepository <Guestbook>();
            string name       = Guid.NewGuid().ToString();
            var    guestbook  = new Guestbook()
            {
                Name = name
            };

            repository.Add(guestbook);
            guestbook.AddEntry(new GuestbookEntry()
            {
                EmailAddress = "*****@*****.**", Message = "test 1"
            });
            repository.Update(guestbook);

            var spec = new GuestbookWithEntriesSpec();

            var result = repository.List(spec).FirstOrDefault(g => g.Name == name);

            Assert.NotNull(result);
            Assert.Equal(1, result.Entries.Count());
        }