简体   繁体   English

我可以在MS.Net Framework 4.0中使用SqlClient的Mono实现吗?

[英]Can I use the Mono implementation of SqlClient in MS.Net framework 4.0?

We are testing some options to solve performance issues with .Net 4.0 SqlClient (lots of GC and finalizers, etc.) and were thinking of using a different Sql client implementation - Mono came to mind. 我们正在测试一些选项来解决.Net 4.0 SqlClient(大量的GC和终结器等)的性能问题,并且正在考虑使用其他Sql客户端实现-想到了Mono。

1) Is it possible to use the Mono implementation of SqlClient with a MS.Net application? 1)是否可以将SqlClient的Mono实现与MS.Net应用程序一起使用? if so- how? 如果是这样-怎么办?
2) Is the Mono implementation "stable"? 2)Mono实现是否“稳定”? which version is most recommended? 最推荐哪个版本?
3) Does the mono implementation of SqlCommand, QueryResults, etc. contain finalizers? 3)SqlCommand,QueryResults等的单声道实现是否包含终结器?

Thanks! 谢谢!

If you are seeing these impact GC, then that suggests you aren't using them properly . 如果您看到这些影响GC的信息,则表明没有正确使用它们 Of these, SqlDataReader doesn't have a finalizer in the first place, so I assume we're talking about SqlCommand and SqlConnection . 其中, SqlDataReader没有终结器,因此我假设我们正在谈论SqlCommandSqlConnection Both of these inherit from Component , and in both cases the Dispose() call unregisters them from GC - it is: 它们都继承自Component ,在两种情况下, Dispose()调用均从GC 取消注册它们-它是:

public void Dispose()
{
    this.Dispose(true);
    GC.SuppressFinalize(this);
}

So: if you are setting these appear as finalizers in GC, look to see whether you are disposing your objects correctly. 因此:如果要设置它们在GC中显示为终结器,请查看是否正确放置了对象。 The easiest way to do that is via using statements. 最简单的方法是通过using语句。 For example: 例如:

using(var conn = OpenSomeConnection())
using(var cmd = conn.CreateCommand()) {
    // TODO configure command

    using(var reader = cmd.ExecuteReader()) {
        // TODO consume data
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM