Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/LinqTests/Acceptance/select_many.cs
Original file line number Diff line number Diff line change
Expand Up @@ -408,10 +408,9 @@ public async Task select_many_with_stats()
await theStore.BulkInsertAsync(targets);

await using var query = theStore.LightweightSession();
QueryStatistics stats;

var actual = query.Query<Target>()
.Stats(out stats)
.Stats(out QueryStatistics stats)
.SelectMany(x => x.Children)
.Where(x => x.Flag)
.OrderBy(x => x.Id)
Expand Down Expand Up @@ -532,8 +531,7 @@ public async Task select_many_with_select_transformation()
public void Bug_665()
{
using var session = theStore.QuerySession();
QueryStatistics stats = null;
var attributes = session.Query<Product>().Stats(out stats).SelectMany(x => x.Attributes)
var attributes = session.Query<Product>().Stats(out QueryStatistics stats).SelectMany(x => x.Attributes)
.Select(x => x.Attribute.Name).Distinct();
}

Expand Down
10 changes: 3 additions & 7 deletions src/LinqTests/Acceptance/statistics_and_paged_list.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,10 @@ public async Task can_get_the_total_in_batch_query()
var count = await theSession.Query<Target>().Where(x => x.Number > 10).CountAsync();
count.ShouldBeGreaterThan(0);

QueryStatistics stats = null;

var batch = theSession.CreateBatchQuery();

var list = batch.Query<Target>().Stats(out stats).Where(x => x.Number > 10).Take(5)
var list = batch.Query<Target>().Stats(out QueryStatistics stats).Where(x => x.Number > 10).Take(5)
.ToList();

await batch.Execute();
Expand All @@ -165,11 +164,10 @@ public async Task can_get_the_total_in_results()
// parameter to the call below, so we
// have to declare the "stats" object
// first
QueryStatistics stats = null;

var list = await theSession
.Query<Target>()
.Stats(out stats)
.Stats(out QueryStatistics stats)
.Where(x => x.Number > 10).Take(5)
.ToListAsync();

Expand All @@ -188,9 +186,7 @@ public async Task can_get_the_total_in_results_async()
var count = await theSession.Query<Target>().Where(x => x.Number > 10).CountAsync();
count.ShouldBeGreaterThan(0);

QueryStatistics stats = null;

var list = await theSession.Query<Target>().Stats(out stats).Where(x => x.Number > 10).Take(5)
var list = await theSession.Query<Target>().Stats(out QueryStatistics stats).Where(x => x.Number > 10).Take(5)
.ToListAsync();

list.Any().ShouldBeTrue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,11 @@ public async Task return_the_correct_number_of_results_when_skip_take_is_after_s

await theSession.SaveChangesAsync();

QueryStatistics stats;

theSession.Logger = new TestOutputMartenLogger(_output);

var queryable = await theSession.Query<Target>()
.Stats(out stats)
.Stats(out QueryStatistics stats)
.Where(_ => _.Color == Colors.Blue)
.OrderBy(_ => _.Number)
.Select(entity => entity.Id)
Expand All @@ -66,10 +65,9 @@ public async Task return_the_correct_number_of_results_when_skip_take_is_before_

await theSession.SaveChangesAsync();

QueryStatistics stats;

var queryable = await theSession.Query<Target>()
.Stats(out stats)
.Stats(out QueryStatistics stats)
.Where(_ => _.Color == Colors.Blue)
.OrderBy(_ => _.Number)
.Skip(10)
Expand Down
3 changes: 1 addition & 2 deletions src/LinqTests/Bugs/Bug_717_permutation_of_Linq_queries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,11 @@ public void do_not_blow_up()
session.Store(entityToStore);

//now try to get the data back
QueryStatistics stats;

/*------------------------------------------------------------------*/
//getting an Exception while trying to execute this query

var entity1 = session.Query<MainEntity>().Stats(out stats).FirstOrDefault(t => t.Entity1.StringValues.Any());
var entity1 = session.Query<MainEntity>().Stats(out QueryStatistics stats).FirstOrDefault(t => t.Entity1.StringValues.Any());

//Marten.MartenCommandException: 'Marten Command Failure:
//select d.data, d.id, d.mt_version, count(1) OVER() as total_rows from public.mt_doc_mainentity as d where JSONB_ARRAY_LENGTH(COALESCE(case when data->>'Entity1'->'StringValues' is not null then data->'Entity1'->'StringValues' else '[]' end)) > 0 LIMIT 1
Expand Down
3 changes: 1 addition & 2 deletions src/Marten/Linq/CollectionUsage.Compilation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ public Statement BuildTopStatement(IMartenSession session, IQueryableMemberColle
var inner = statement.Top();
var selectionStatement = inner.SelectorStatement();

ITenantFilter? tenantWhereFragment = null;
selectionStatement.TryFindTenantAwareFilter(out tenantWhereFragment);
selectionStatement.TryFindTenantAwareFilter(out ITenantFilter? tenantWhereFragment);


if (inner is SelectorStatement { SelectClause: IDocumentStorage } select)
Expand Down
Loading