Esempio n. 1
0
        protected override IQueryOver GetQueryOver <TResult>(GetFilmsQuery query)
        {
            FilmRatingDto filmRatingDto = null;

            return(Session.QueryOver <LocationFilmDto>()
                   .Where(x => x.CountryCode == query.CountryCode &&
                          x.LocationNameOrPostCode == query.LocationNameOrPostCode
                          )
                   .JoinAlias(x => x.Ratings, () => filmRatingDto)
                   .Where(() => filmRatingDto.RatingSource == query.RatingSource &&
                          filmRatingDto.Rating >= query.MinimalRating)
                   );
        }
Esempio n. 2
0
        public void Context()
        {
            var country = new CountryBuilder().Build();

            UnitOfWork.Save(country);

            var cinema = new CinemaBuilder().Build();

            UnitOfWork.Save(cinema);

            _film = new FilmBuilder().Build();
            UnitOfWork.Save(_film);

            var location = new LocationBuilder()
                           .WithCountry(country)
                           .WithLocationFilms(new LocationFilmArgs
            {
                Film    = _film,
                Cinemas = new[]
                {
                    new LocationFilmCinemaArgs {
                        Cinema = cinema
                    }
                }
            })
                           .Build();

            UnitOfWork.Save(location);

            UnitOfWork.Clear();

            var locationFilmId = location.Films.Single().Id;

            _filmRatingDto = UnitOfWork.Session.QueryOver <LocationFilmDto>()
                             .Where(x => x.Id == locationFilmId)
                             .List().Single()
                             .Ratings.SingleOrDefault();
        }