Exemplo n.º 1
0
        /// <summary>
        /// Executes a command that returns a single value.
        /// </summary>
        /// <param name="commandText">The command text.</param>
        /// <param name="parameters">The parameters.</param>
        /// <returns>The return value of the command.</returns>
        protected override object ExecuteScalar(string commandText, SqlCeParameter[] parameters)
        {
            #if DEBUG && DebugDataLayer
            // Log Query Execution
            Trace.TraceInformation(GetType().Name + " SQL ExecuteScalar: " + commandText);
            #endif

            return(SqlCeApplicationBlock.ExecuteScalar(ConnectionString, CommandType.Text, commandText, parameters));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Executes a command and returns a records reader containing the results.
        /// </summary>
        /// <param name="commandText">The command text.</param>
        /// <param name="parameters">The parameters.</param>
        /// <returns>
        /// A data reader containing the results of the command.
        /// </returns>
        protected override IRecordsReader ExecuteReader(string commandText, SqlCeParameter[] parameters)
        {
            #if DEBUG && DebugDataLayer
            // Log Query Execution
            Trace.TraceInformation(GetType().Name + " SQL ExecuteReader: " + commandText);
            #endif

            return(new SqlCeDataReaderHelper(SqlCeApplicationBlock.ExecuteReader(ConnectionString, CommandType.Text,
                                                                                 commandText, parameters)));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Executes a command that returns a single value.
        /// </summary>
        /// <param name="commandText">The command text.</param>
        /// <param name="parameters">The parameters.</param>
        /// <returns>The return value of the command.</returns>
        protected override object ExecuteScalar(string commandText, SqlCeParameter[] parameters)
        {
#if DEBUG && DebugDataLayer
            // Log Query Execution
            Trace.TraceInformation(GetType().Name + " SQL ExecuteScalar: " + commandText);
#endif
            using (var cc = UseCurrentConnection)
            {
                return(SqlCeApplicationBlock.ExecuteScalar(
                           (SqlCeConnection)cc.Connection, (SqlCeTransaction)cc.Transaction,
                           CommandType.Text, commandText, parameters));
            }
        }
Exemplo n.º 4
0
        // We need to override this as the default way of detection a db connection checks for systables that doesn't exist
        // in a CE db
        protected override DatabaseVersion DetermineCurrentVersion()
        {
            DatabaseVersion version = base.DetermineCurrentVersion();

            if (version != DatabaseVersion.Unavailable)
            {
                return(version);
            }

            // verify connection
            try
            {
                if (SqlCeApplicationBlock.VerifyConnection(base.SqlHelper.ConnectionString))
                {
                    return(DatabaseVersion.None);
                }
            }
            catch (Exception e)
            {
                Trace.WriteLine(e.ToString());
            }

            return(DatabaseVersion.Unavailable);
        }