예제 #1
0
        public IPersistanceData Get(long persistanceDataId)
        {
            IPersistanceData result = null;

            using (var connection = new SqlConnectionWithExceptionLogger(this._loggingService, this._connectionStringValue))
            {
                connection.Open();
                connection.TryExecute(() =>
                {
                    var command         = connection.CreateCommand();
                    command.CommandType = CommandType.Text;
                    command.CommandText =
                        "SELECT [SomeData] FROM [dbo].[ufn_GetPersistedData](@PersistanceDataId)";
                    command.Parameters.AddWithValue("@PersistanceDataId", persistanceDataId);
                    using (var reader = command.ExecuteReader())
                    {
                        if (reader.Read())
                        {
                            result = new PersistanceData
                            {
                                SomeData = reader.GetString(0)
                            };
                        }
                    }
                });
            }
            return(result);
        }
예제 #2
0
 private static void UpdateStateData(SqlConnectionWithExceptionLogger connection, IPersistanceData entityToUpdate)
 {
     connection.TryExecute(() =>
     {
         using (var command = connection.CreateCommand())
         {
             command.CommandType = CommandType.StoredProcedure;
             command.CommandText = "[dbo].[usp_UpdateData]";
             command.Parameters.AddWithValue("@PersistanceProcessId", entityToUpdate.PersistanceDataId);
             command.ExecuteNonQuery();
         }
     });
 }
예제 #3
0
 public void Delete(long persistanceDataId)
 {
     using (var connection = new SqlConnectionWithExceptionLogger(this._loggingService, this._connectionStringValue))
     {
         connection.Open();
         connection.TryExecute(() =>
         {
             using (var command = connection.CreateCommand())
             {
                 command.CommandType = CommandType.StoredProcedure;
                 command.CommandText = "[dbo].[usp_DeleteData]";
                 command.Parameters.AddWithValue("@PersistanceDataId", persistanceDataId);
                 command.ExecuteNonQuery();
             }
         });
     }
 }
예제 #4
0
 private static void CreateStateData(SqlConnectionWithExceptionLogger connection, IPersistanceData entityToCreate)
 {
     connection.TryExecute(() =>
     {
         using (var command = connection.CreateCommand())
         {
             command.CommandType = CommandType.StoredProcedure;
             command.CommandText = "[dbo].[usp_InsertData]";
             command.Parameters.AddWithValue("@Data", entityToCreate.SomeData);
             var outPutParameter = new SqlParameter
             {
                 ParameterName = "@PersistanceDataId",
                 SqlDbType     = SqlDbType.BigInt,
                 Direction     = ParameterDirection.Output
             };
             command.Parameters.Add(outPutParameter);
             command.ExecuteNonQuery();
             entityToCreate.PersistanceDataId = (long)outPutParameter.Value;
         }
     });
 }