Lets say I want to display some data on webpage, so I Load the data:
using (KEntities ctx = new KEntities())
{
ctx.KSet.MergeOption = MergeOption.NoTracking;
var items = (from c in ctx.KSet
where c.ParentId == 0
select new
{
Title = c.Title,
Id = c.Id,
Subs = ctx.KSet.Where(o => o.ParentId == c.Id)
}).ToList();
}
Is there any benefit using MergeOption.NoTracking?
If now, when should I use it?
Yes, if you only want the data, then use MergeOption.NoTracking. This means they wont be stored in the graph that keeps track of the entity for updating and deleting. This helps performance alittle in terms of memory.