开发者

Can you make Linq-to-SQL get rid of lazy loaded properties after they are saved?

开发者 https://www.devze.com 2022-12-15 19:53 出处:网络
I have an application that uses Linq-to-SQL and stores very large objects. When it\'s processing and saving these new objects, I want to keep them in memory, but after it saves I want to get rid of th

I have an application that uses Linq-to-SQL and stores very large objects. When it's processing and saving these new objects, I want to keep them in memory, but after it saves I want to get rid of the lazy loaded property (the one that is taking up all the memory).

Is there any way to do this without just getting rid of the object and reloading it from the database? I know I can do that, but I'm 开发者_开发知识库hoping for a cleaner way of just telling it "relase this property on save"...

Thoughts?


I believe you can do this by detaching the entity from the database context. You can do this as follows:

    public virtual void Detach()
    {
        PropertyChanging = null;
        PropertyChanged = null;
    }
0

精彩评论

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