entity framework - Multiple contexts and MergeOption -


setting mergeoption on entityset overrides caching behavior of subsequent queries on entityset -- that's clear.

however, seems setting mergeoption on entityset 1 context affects caching behavior of queries on other contexts...

example:

using (var db1 = new context()) {     db1.table.mergeoption = mergeoption.notrack;      using (var db2 = new context()) {         var record = db2.table.firstordefault();         // record *detached*     } } 

the way caching behavior on db2 convert query objectquery , change query's mergeoption. use following handy extension method:

public static objectresult<t> withmergeoption<t> (this iqueryable<t> query, mergeoption mergeoption) {     return (query objectquery<t>).execute(mergeoption); } 

is expected behavior entityset's mergeoption? behaves if overrides static default instead of default on context instance.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -