Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Account for DbContext tracking #9

Open
soljarka opened this issue Nov 26, 2020 · 0 comments
Open

Account for DbContext tracking #9

soljarka opened this issue Nov 26, 2020 · 0 comments

Comments

@soljarka
Copy link

When I send several queries with similar arguments yet different asOf timestamps using a single instance of DbContext, I always get similar results, apparently because of tracking. I solve this issue in my code by adding AsNoTracking():

        public static IQueryable<TSource> AsOfConditional<TSource>(this IQueryable<TSource> source, DateTime? asOf)
        where TSource : class
        {
            if (asOf.HasValue)
                return source.AsOf(asOf.Value).AsNoTracking();

            return source;
        }

This may be not the responsibility of this library, but it might be helpful to extend AsOf() or at least give users some hints.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant