是否需要关闭sqlite的连接

时间:2020-03-08 09:43:18

标签: xamarin android-sqlite

我在许多教程中都读到,不必在xamarin sqlite中关闭连接,因为它不像 ADO.NET 中的连接,它就像 Entityframework < / strong>,但在某些教程中,据说有必要关闭连接

这是xamarin代码

private readonly SQLiteAsyncConnection _connection;

public ExperiencePage()
{
   InitializeComponent();

   _connection = DependencyService.Get<ISqLiteDb>().GetConnection();
}

是否需要关闭连接?

1 个答案:

答案 0 :(得分:0)

我认为没有必要关闭连接,但是应该如何处置它或使用using语句将其作为IDisposable对象。

using(SqlConnection connection = new SqlConnection("ConnectionString"))
    {
         // some code here
     }