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

Query IncludeFilter with AsNoTracking #79

Open
tojo4 opened this issue Nov 14, 2016 · 3 comments
Open

Query IncludeFilter with AsNoTracking #79

tojo4 opened this issue Nov 14, 2016 · 3 comments
Assignees

Comments

@tojo4
Copy link

tojo4 commented Nov 14, 2016

Hi all,

we are trying to use the Query IncludeFilter feature on a query with the AsNoTracking attribute. We noticed that all of the navigation properties, which are supposed to be included, are null.

Is this a known issue, and is there any workaround we can use?

Regards,
Tom

@zzzprojects zzzprojects self-assigned this Nov 15, 2016
@zzzprojects
Copy link
Collaborator

Unfortunately, our library transforms the query to an anonymous type

From

ctx.Association_OneToMany_Lefts
     .IncludeFilter(x => x.Rights.OrderByDescending(y => y.ID))
     .AsNoTracking().ToList();

To

ctx.Association_OneToMany_Lefts
    .Select(x => new {x, x.Rights})
    .AsNoTracking().ToList();

To add relation included (in both example) automatically, the ChangeTracking must be enabled.

We will check this weekend if we can find a workaround. I believe the only possible solution will be to create a new context and use the change tracker within it when we found the "AsNoTracking" method is used. So the passed context will not be impacted by the performance and will not track entities returned either.

@zzzprojects zzzprojects removed their assignment Jan 2, 2017
@JonathanMagnan JonathanMagnan self-assigned this Jan 3, 2017
@andrew-lis
Copy link

I suggest to make a warning on IncludeFilter wiki page, that it doesn't work currently with AsNoTracking. I've spent 1 hour fighting with this...

@JonathanMagnan
Copy link
Member

Hello @andrew-lis ,

Yes, you are right. Sorry for the time you lost ;(

The Wiki has been updated.

Best Regards,

Jonathan

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

No branches or pull requests

3 participants