Open VadimOvchinnikov opened 1 year ago
Yes it does. Using AsNoTracking
on basically every "read-only" interaction with the context is probably a good idea.
The reason this is not mentioned in OData documentation is probably because it really is not an OData-specific concern, I'd imagine. Usually you want the documentation for your product/library to focus on concerns only for your library and leave as much of external things out.
Also, at the end of the day, we are talking about an optimization here. Usually samples don't include them, as well.
Maybe the full actual project samples should consider using it though.
Thanks @julealgon, we will try this out in one of our samples, and we agreed that we should update the docs to use this since it would be best practice in those cases.
There is
.AsNoTracking()
method in EF Core which ensures minimal memory usage and optimal performance for read operation. When I found examples of OData controllers online, I've never seen using.AsNoTracking()
forGet
andGet(id)
methods. For example, in MS docs bothdon't use it.
So, does it make sense to use it for OData read queries?