ObjectContext的内存消耗和性能 [英] ObjectContext memory consumption and performance

查看:112
本文介绍了ObjectContext的内存消耗和性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在一定程度上使得负责保存自己的每一个变化的实体对象写一个业务对象层。

I want to write a business object layer in a way that makes each entity object responsible for saving its own changes.

我认为这将是一个很好的方式让每个实体posses自己的ObjectContext的,自身附加到ObjectContext的并执行交易时,它需要被保存。

I thought it would be a good way to have each entity posses its own ObjectContext, attach itself to that ObjectContext and perform the transaction whenever it needs to be saved.

在LINQ到SQL,DataContext的非常轻巧,因此我的解决方案并没有太多的内存消耗和性能损失。是不是同样具有ObjectContext的?

In LINQ to SQL, DataContext is very lightweight and thus my solution doesn't have too much memory consumption and performance loss. Is it the same with the ObjectContext?

和什么有关附加对象?是不是像LINQ工作,SQL或不是一个沉重的单位?

And what about attaching objects? Is it a heavy unit of work like LINQ to SQL or not?

推荐答案

有人认为的对象的不应该的负责这一点;他们的工作是重新present实例化对象;这是另一个类的(资料库)工作坚持它。

It has been argued that objects shouldn't be responsible for this; their job is to represent instantiated object; it is the job of another (repository) class to persist it.

ObjectContext的可以是一个痛苦,当涉及到安装/拆卸对象,因为(不像LINQ到SQL)有上下文和实体之间的更紧密耦合。就个人而言,我不会使用这种方法;我会使用实体本身(或工作副本)作为工作的瞬变单元以及一个短暂的上下文。

ObjectContext can be a pain when it comes to attaching/detaching objects, since (unlike LINQ-to-SQL) there is a much tighter coupling between the context and the entity. Personally, I wouldn't use this approach; I'd use the entity itself (or a working copy) as a transient unit of work along with a short-lived context.

这篇关于ObjectContext的内存消耗和性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆