Skip to content

Translation of DateTime.UtcNow inside queries #1070

@alansbraga

Description

@alansbraga

Hi.
I'm using openiddict-core and I'm having an issue when they try to prune all inactive connections.

They are using this query

            var date = threshold.UtcDateTime;

            var tokens = await
                (from token in Tokens.AsTracking()
                 where token.CreationDate < date
                 where (token.Status != Statuses.Inactive && token.Status != Statuses.Valid) ||
                       (token.Authorization != null && token.Authorization.Status != Statuses.Valid) ||
                        token.ExpirationDate < DateTime.UtcNow
                 orderby token.Id
                 select token).Take(1_000).ToListAsync(cancellationToken);

I've fixed changing to this

            var date = threshold.UtcDateTime;
            var expirationDate = DateTime.UtcNow;

            var tokens = await
                (from token in Tokens.AsTracking()
                 where token.CreationDate < date
                 where (token.Status != Statuses.Inactive && token.Status != Statuses.Valid) ||
                       (token.Authorization != null && token.Authorization.Status != Statuses.Valid) ||
                        token.ExpirationDate < expirationDate 
                 orderby token.Id
                 select token).Take(1_000).ToListAsync(cancellationToken);

As you can see on their issue: openiddict/openiddict-core#1507 (comment)

They asked me to create this issue here to verify if you intend to translate DateTime.UtcNow inside queries.

Thank you in advance.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions