среда, 25 ноября 2015 г.

EntityFramework AutoDetectChanges

https://msdn.microsoft.com/en-us/data/jj556205.aspx

using (var context = new BloggingContext()) 
{ 
    try 
    { 
        context.Configuration.AutoDetectChangesEnabled = false; 
 
        // Make many calls in a loop 
        foreach (var blog in aLotOfBlogs) 
        { 
            context.Blogs.Add(blog); 
        } 
    } 
    finally 
    { 
        context.Configuration.AutoDetectChangesEnabled = true; 
    } 
}
Don’t forget to re-enable detection of changes after the loop —
 We've used a try/finally to ensure it is always re-enabled even if code in the loop throws an exception.
An alternative to disabling and re-enabling is to leave automatic detection of changes turned off
 at all times and either call context.ChangeTracker.DetectChanges explicitly 
or use change tracking proxies diligently.
 Both of these options are advanced and can easily introduce subtle bugs into your application
 so use them with care.

http://stackoverflow.com/questions/16863382/dbcontext-autodetectchangesenabled-set-to-false-detecting-changes

http://blog.staticvoid.co.nz/2012/5/7/entityframework_performance_and_autodetectchanges

http://blog.oneunicorn.com/category/entity-framework/change-tracking/

http://blog.oneunicorn.com/2012/03/10/secrets-of-detectchanges-part-1-what-does-detectchanges-do/

http://blog.oneunicorn.com/2012/03/12/secrets-of-detectchanges-part-3-switching-off-automatic-detectchanges/

SqlBulkCopy

http://habrahabr.ru/post/251397/

Комментариев нет:

Отправить комментарий