为什么DataAdapter的不是一次性 [英] Why DataAdapter is not Disposable

查看:107
本文介绍了为什么DataAdapter的不是一次性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道有可能是一个明显的原因,但我不能找到它。

I know there is probably an obvious reason but I can't find it..

数据库连接和数据读取的时候,我通常会使用使用语句,但我不能 DataAdapter的,因为它不执行的IDisposable

I usually use the using statement during DB connection and data reading, but I can't use it on DataAdapter because it doesn't implement IDisposable.

另外:如何能表现填充数据集之后?

Also: how can it behave after filling a dataset?

是否关闭自己的连接?

Does it close itself the connection?

只有将其关闭或处置的呢?

Only close it or dispose it?

我必须处理的数据集灌装后自己的内在联系?如果是这样,为什么 IDataAdapter 没有一个相关的属性/方法?

Do I have to dispose the internal connection by myself after the dataset filling? If so, why IDataAdapter doesn't have a related property/method?

推荐答案

DataAdapter的不到风度实现IDisposable,因为它没有需要进行常规的垃圾收集处理以外的任何成员变量。换句话说,它并不需要实现IDisposable

DataAdapter dosn't implement IDisposable because it doesn't have any member variables that need to be handled outside of normal garbage collection. In other words it doesn't need to implement IDisposable.

如果你intrested你可以看到源$ C ​​$ C到单声道DataAdapter的位置:<一href="http://www.java2v.com/Open-Source/CSharp/2.6.4-mono-.net-core/System.Data/System/Data/Common/DataAdapter.cs.htm" rel="nofollow">http://www.java2v.com/Open-Source/CSharp/2.6.4-mono-.net-core/System.Data/System/Data/Common/DataAdapter.cs.htm

If your intrested you can see the source code to the Mono DataAdapter here : http://www.java2v.com/Open-Source/CSharp/2.6.4-mono-.net-core/System.Data/System/Data/Common/DataAdapter.cs.htm

在一般的,如果你要使用它后,关闭连接,继续在投入了使用范围内的连接,但它的确定也有一个独立的,并在使用相同的连接multipal范围multipal DataAdapters。

In general if you going to close the connection after using it, go ahead in put the connection in a using scope, but its ok too to have a singleton and have multipal DataAdapters in multipal scopes using the same connection.

希望这是有道理的。

这篇关于为什么DataAdapter的不是一次性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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