开发者

Is it possible to use NoTracking (MergeOption.NoTracking) with the EntityDatSource Control?

Can anyone t开发者_JAVA技巧ell me if it is possible to use NoTracking (MergeOption.NoTracking) with the EntityDatSource Control?

If so, how?


Implement handling for ContextCreating event and set MergeOption for ObjectSet<T>:

public partial class YourPage : System.Web.UI.Page
{
    ...

    protected void EntityDataSource_ContextCreating(object sender, 
        EntityDataSourceContextCreatingEventArgs e)
    {
        e.Context = new YourContext();  // EntityDataSource handles disposing
        e.Context.YourObjectSet.MergeOption = MergeOption.NoTracking;
    }
}

And in the markup use:

<asp:EntityDataSource ... OnContextCreating="EntityDataSource_ContextCreating" />
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜