private int QueryAllArtists(Benchmark bench)
 {
     using (var q = Query.Select(SelectResult.Expression(Expression.Property("Artist")))
                    .From(DataSource.Database(Db))
                    .Where(Expression.Property("Artist").NotNullOrMissing()
                           .And(Expression.Property("Compilation").IsNullOrMissing()))
                    .GroupBy(Expression.Property("Artist"))
                    .OrderBy(Ordering.Property("Artist"))) {
         bench.Start();
         _artists = CollectQueryResults(q);
         bench.Stop();
         _artists.Count.Should().Be(1111);
         return(_artists.Count);
     }
 }
Example #2
0
        private void VerifyByTagName(string tag, Action <int, IResult> verify)
        {
            var TAG_EXPR = Expression.Property("tag");
            var DOCID    = SelectResult.Expression(Meta.ID);
            var ds       = DataSource.Database(Db);

            using (var q = Query.Select(DOCID).From(ds).Where(TAG_EXPR.EqualTo(tag))) {
                WriteLine($"query -> {(q as XQuery).Explain()}");
                using (var rs = q.Execute()) {
                    int n = 0;
                    foreach (var row in rs)
                    {
                        verify(++n, row);
                    }
                }
            }
        }
        private int QueryAlbums(Benchmark bench)
        {
            var albumCount = 0;

            using (var q = Query.Select(SelectResult.Expression(Expression.Property("Album")))
                           .From(DataSource.Database(Db))
                           .Where(Expression.Property("Artist").EqualTo(Expression.Parameter("ARTIST")
                                                                        .And(Expression.Property("Compilation").IsNullOrMissing())))
                           .GroupBy(Expression.Property("Album"))
                           .OrderBy(Ordering.Property("Album"))) {
                bench.Start();

                foreach (var artist in _artists)
                {
                    q.Parameters.Set("ARTIST", artist);
                    var albums = CollectQueryResults(q);
                    albumCount += albums.Count;
                }
            }

            bench.Stop();
            albumCount.Should().Be(1886);
            return(albumCount);
        }