public void CountShouldBeExecutedOnTheServerSide() { using var context = CreateBookStoreContext(); var logReader = new SimpleLineWriter(); context.StartLogging(logReader); context .Books .AsNoTracking() .Count(); logReader.GetString().ToLower().Should().Contain("count", "because the whole query is queryable and SQL server has COUNT function"); }
public void CountShouldBeExecutedOnTheClientSide() { using var context = CreateBookStoreContext(); var logReader = new SimpleLineWriter(); context.StartLogging(logReader); context .Books .AsNoTracking() .AsEnumerable() .Count(); logReader.GetString().ToLower().Should().NotContain("count", "because AsEnumerable() makes the query no longer queryable"); }