Example #1
0
        /// <summary>
        ///		<para>Creates a connection for this database.</para>
        /// </summary>
        /// <remarks>
        ///		This method has been overridden to support keeping a single connection open until you
        ///		explicitly close it with a call to <see cref="CloseSharedConnection"/>.
        /// </remarks>
        /// <returns>
        ///		<para>The <see cref="DbConnection"/> for this database.</para>
        /// </returns>
        /// <seealso cref="DbConnection"/>
        public override DbConnection CreateConnection()
        {
            DbConnection connection = SqlCeConnectionPool.CreateConnection(this);

            connection.ConnectionString = ConnectionString;
            return(connection);
        }
 /// <summary>
 ///        <para>Creates a connection for this database.</para>
 /// </summary>
 /// <remarks>
 ///        This method has been overridden to support keeping a single connection open until you
 ///        explicitly close it with a call to <see cref="CloseSharedConnection"/>.
 /// </remarks>
 /// <returns>
 ///        <para>The <see cref="DbConnection"/> for this database.</para>
 /// </returns>
 /// <seealso cref="DbConnection"/>
 public override DbConnection CreateConnection()
 {
     using (DatabaseConnectionWrapper wrapper = SqlCeConnectionPool.CreateConnection(this))
     {
         wrapper.AddRef();
         wrapper.Connection.ConnectionString = ConnectionString;
         return(wrapper.Connection);
     }
 }
Example #3
0
 /// <summary>
 ///		This will close the "keep alive" connection that is kept open once you first access
 ///		the database through this class. Calling this method will close the "keep alive"
 ///		connection for all instances. The next database access will open a new "keep alive"
 ///		connection.
 /// </summary>
 public void CloseSharedConnection()
 {
     SqlCeConnectionPool.CloseSharedConnection(this);
 }
 /// <summary>
 /// Gets a "wrapped" connection for use outside a transaction.
 /// </summary>
 /// <returns>The wrapped connection.</returns>
 protected override DatabaseConnectionWrapper GetWrappedConnection()
 {
     return(SqlCeConnectionPool.CreateConnection(this, true));
 }