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

Extra overloading Fetch methods using AsNoTracking() #11

Closed
jersiovic opened this issue Jan 30, 2015 · 3 comments
Closed

Extra overloading Fetch methods using AsNoTracking() #11

jersiovic opened this issue Jan 30, 2015 · 3 comments
Assignees

Comments

@jersiovic
Copy link
Contributor

What do you think of offering extra overloads for Fetch methods that use AsNoTracking in order to improve performance?

    public virtual IQueryable<T> FetchWithNoTracking(Expression<Func<T, bool>> predicate)
    {
        return Table.AsNoTracking().Where(predicate);
    }

Indeed in order to help devs to don't forget to use the most most optimal one I would use:

public virtual IQueryable<T> Fetch(Expression<Func<T, bool>> predicate)
        {
            return Table.AsNoTracking().Where(predicate);
        }

public virtual IQueryable<T> FetchWithTracking(Expression<Func<T, bool>> predicate) {
            return Table.Where(predicate);
        }

Problem is it is a breaking change, so to avoid unnoticed bad uses of the Fech method maybe it will be better to remove Fech method and only have FetchWithTracking and FetchWithNoTracking methods.

What do you think?

@Jetski5822
Copy link
Member

Maybe we should have this by default, then on Flush it checks to see if the items are attached and reattach then if dirty save changes? Does the DbContext have an even for that?

@jersiovic
Copy link
Contributor Author

Problem I see with this solution is we would spend extra processing time doing dirty checking just because we don't want to bother consumer code forcing it to ask us if the data it is going to consume is read only or not.
Read only queries are the most common ones so to avoid a lot of extra work we should avoid dirty checking for data related with those queries. The point is that who knows if a query needs tracking or not is the code who asks the query and consumes its data. So why don't let this code take the decision (it is easy to do it at this level)? In this way we avoid to lose processing time making a trick in repository to don't delegate the decision on who should take it.

@Jetski5822 Jetski5822 added this to the Data layer milestone Feb 2, 2015
@Jetski5822 Jetski5822 self-assigned this Apr 20, 2015
@Jetski5822
Copy link
Member

This is abstracted to the individual ContentStore. The content store implementation will dictate is a object is tracked or not, not the calling layer.

DrewScoggins added a commit to DrewScoggins/OrchardCore that referenced this issue Jan 19, 2024
DrewScoggins added a commit to DrewScoggins/OrchardCore that referenced this issue Jan 23, 2024
Skrypt pushed a commit that referenced this issue Jan 25, 2024
^ This is the 1st commit message:

Add GetCulture() extension method

^ This is the commit message #2:

Cleanup ISmsService (#15142)


^ This is the commit message #3:

Fix TheAdminTheme layout margin and padding (#15143)


^ This is the commit message #4:

Fix SectionDisplayDriver prefix (#15123)


^ This is the commit message #5:

Prefill template name when creating a template. (#15145)


^ This is the commit message #6:

Set the User Localization feature priority

^ This is the commit message #7:

Fix issue with default culture not selected

When currentUserCulture is null or supportedCulture doesn't contain currentUserCulture.

^ This is the commit message #8:

Update the height of the admin content (#15153)


^ This is the commit message #9:

Eliminate the anti-discovery pattern in Elasticsearch (#15134)


^ This is the commit message #10:

Renaming and cleaning up search services (#15156)


^ This is the commit message #11:

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

No branches or pull requests

2 participants