/// <summary>
 ///     Initializes a new instance of the <see cref="MsSqlMessageStore" /> class.
 ///     Use this constructor if you need to pass in the logger
 /// </summary>
 /// <param name="configuration">The configuration.</param>
 /// <param name="log">The log.</param>
 public MsSqlMessageStore(MsSqlMessageStoreConfiguration configuration, ILog log)
 {
     _configuration            = configuration;
     _log                      = log;
     _javaScriptSerializer     = new JavaScriptSerializer();
     ContinueOnCapturedContext = false;
 }
Beispiel #2
0
        private void SetPagingCommandFor(DbCommand command, MsSqlMessageStoreConfiguration configuration, int pageSize,
                                         int pageNumber)
        {
            var pagingSqlFormat = "SELECT * FROM (SELECT ROW_NUMBER() OVER(ORDER BY Timestamp DESC) AS NUMBER, * FROM [{0}]) AS TBL WHERE NUMBER BETWEEN ((@PageNumber-1)*@PageSize+1) AND (@PageNumber*@PageSize) ORDER BY Timestamp DESC";
            var parameters      = new[]
            {
                CreateSqlParameter("PageNumber", pageNumber),
                CreateSqlParameter("PageSize", pageSize)
            };

            var sql = string.Format(pagingSqlFormat, _configuration.MessageStoreTableName);

            command.CommandText = sql;
            command.Parameters.AddRange(parameters);
        }
        private void SetPagingCommandFor(DbCommand command, MsSqlMessageStoreConfiguration configuration, int pageSize,
                                         int pageNumber)
        {
            string pagingSqlFormat;

            DbParameter[] parameters;
            switch (configuration.Type)
            {
            case MsSqlMessageStoreConfiguration.DatabaseType.MsSqlServer:
                //works 2005+
                pagingSqlFormat =
                    "SELECT * FROM (SELECT ROW_NUMBER() OVER(ORDER BY Timestamp DESC) AS NUMBER, * FROM {0}) AS TBL WHERE NUMBER BETWEEN ((@PageNumber-1)*@PageSize+1) AND (@PageNumber*@PageSize) ORDER BY Timestamp DESC";
                parameters = new[]
                {
                    CreateSqlParameter("PageNumber", pageNumber)
                    , CreateSqlParameter("PageSize", pageSize)
                };
                break;

            case MsSqlMessageStoreConfiguration.DatabaseType.SqlCe:
                //2012+/ce only
                pagingSqlFormat =
                    "SELECT * FROM {0} ORDER BY Timestamp DESC OFFSET @Offset ROWS FETCH NEXT @PageSize ROWS ONLY";
                parameters = new[]
                {
                    CreateSqlParameter("Offset", (pageNumber - 1) * pageSize)
                    //sqlce doesn't like arithmetic in offset...
                    , CreateSqlParameter("PageSize", pageSize)
                };
                break;

            default:
                throw new ArgumentException("Cannot generate command for sql env " + configuration.Type);
            }

            var sql = string.Format(pagingSqlFormat, _configuration.MessageStoreTableName);

            command.CommandText = sql;
            command.Parameters.AddRange(parameters);
        }
 /// <summary>
 ///     Initializes a new instance of the <see cref="MsSqlMessageStore" /> class.
 /// </summary>
 /// <param name="configuration">The configuration.</param>
 public MsSqlMessageStore(MsSqlMessageStoreConfiguration configuration)
     : this(configuration, LogProvider.GetCurrentClassLogger())
 {
 }
Beispiel #5
0
 public MsSqlMessageStore(MsSqlMessageStoreConfiguration configuration, ILog log)
 {
     _configuration = configuration;
     _log           = log;
 }
Beispiel #6
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="MsSqlMessageStore" /> class.
 ///     Use this constructor if you need to pass in the logger
 /// </summary>
 /// <param name="configuration">The configuration.</param>
 /// <param name="log">The log.</param>
 public MsSqlMessageStore(MsSqlMessageStoreConfiguration configuration, ILog log)
 {
     _configuration            = configuration;
     _log                      = log;
     ContinueOnCapturedContext = false;
 }
Beispiel #7
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="MsSqlMessageStore" /> class.
 /// </summary>
 /// <param name="configuration">The configuration.</param>
 public MsSqlMessageStore(MsSqlMessageStoreConfiguration configuration)
     : this(configuration, LogProvider.For <MsSqlMessageStore>())
 {
 }
Beispiel #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MsSqlMessageStore"/> class.
 /// Use this constructor if you need to pass in the logger
 /// </summary>
 /// <param name="configuration">The configuration.</param>
 /// <param name="log">The log.</param>
 public MsSqlMessageStore(MsSqlMessageStoreConfiguration configuration, ILog log)
 {
     _configuration        = configuration;
     _log                  = log;
     _javaScriptSerializer = new JavaScriptSerializer();
 }
 /// <summary>
 ///     Initializes a new instance of the <see cref="MsSqlMessageStore" /> class.
 /// </summary>
 /// <param name="configuration">The configuration.</param>
 public MsSqlMessageStore(MsSqlMessageStoreConfiguration configuration)
 {
     _configuration            = configuration;
     ContinueOnCapturedContext = false;
 }