public void Should_cache_the_subquery() { using (var context = new ClientContext()) { var projection = ProjectTo <ProductModel>(context.Products); var counter = new FirstOrDefaultCounter(); counter.Visit(projection.Expression); counter.Count.ShouldBe(1); var productModel = projection.First(); productModel.Price.RegionId.ShouldBe((short)1); productModel.Price.IsDefault.ShouldBeTrue(); productModel.Price.Id.ShouldBe(1); productModel.Id.ShouldBe(1); } }
public void Should_cache_the_subquery() { using (var context = new ClientContext()) { var projection = context.ProductArticles.ProjectTo <ProductArticleModel>(Configuration); var counter = new FirstOrDefaultCounter(); counter.Visit(projection.Expression); counter.Count.ShouldBe(1); var productModel = projection.First().Products.First(); Check(productModel.Articles); productModel.Id.ShouldBe(1); productModel.ArticlesCount.ShouldBe(1); productModel.ArticlesModel.Articles.Count.ShouldBe(1); Check(productModel.ArticlesModel.Articles.Single()); } }
public void Should_cache_the_subquery() { using (var context = new ClientContext()) { var projection = context.ProductArticles.ProjectTo <ProductArticleModel>(Configuration); var counter = new FirstOrDefaultCounter(); counter.Visit(projection.Expression); counter.Count.ShouldEqual(2); var productArticleModel = projection.First(); var productModel = productArticleModel.Product; productModel.Price.RegionId.ShouldEqual((short)1); productModel.Price.IsDefault.ShouldBeTrue(); productModel.Price.Id.ShouldEqual(1); productModel.Id.ShouldEqual(1); var otherProductModel = productArticleModel.OtherProduct; otherProductModel.Price.RegionId.ShouldEqual((short)1); otherProductModel.Price.IsDefault.ShouldBeTrue(); otherProductModel.Price.Id.ShouldEqual(2); otherProductModel.Id.ShouldEqual(2); } }