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

AsNoTracking? #244

Open
VictorioBerra opened this issue Oct 25, 2019 · 5 comments

Comments

@VictorioBerra
Copy link

@VictorioBerra VictorioBerra commented Oct 25, 2019

How do I set AsNoTracking when using a regular repo?

@omarpiani

This comment has been minimized.

Copy link
Member

@omarpiani omarpiani commented Oct 25, 2019

repo.AsQueryable().AsNoTracking()

@VictorioBerra

This comment has been minimized.

Copy link
Author

@VictorioBerra VictorioBerra commented Oct 25, 2019

And then how would you start using repo methods like FindAll? You cant chain anymore. AKA how can you use FindAll + AsNoTracking in a single statement?

@omarpiani

This comment has been minimized.

Copy link
Member

@omarpiani omarpiani commented Oct 26, 2019

no, write an IRepository<> extension to get your particular linq ef specific query in a row.

I have some memory of this, I will search later, maybe we can put AsNoTracking in specifications

@VictorioBerra

This comment has been minimized.

Copy link
Author

@VictorioBerra VictorioBerra commented Oct 26, 2019

@omarpiani

This comment has been minimized.

Copy link
Member

@omarpiani omarpiani commented Oct 27, 2019

something like

public IQueryable<Order> FindAllAsNoTracking(this IRepository<Order,int> repository, Func<Order, bool>  predicate) {
 return repo.AsQueryable().AsNoTracking().Where(predicate);
}

in a static class

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.