コード例 #1
0
ファイル: PersistanceService.cs プロジェクト: ristica/logging
        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
ファイル: PersistanceService.cs プロジェクト: ristica/logging
 public void Create(IPersistanceData entityToCreate)
 {
     using (var connection = new SqlConnectionWithExceptionLogger(this._loggingService, this._connectionStringValue))
     {
         connection.Open();
         connection.TryExecute(() =>
         {
             CreateStateData(connection, entityToCreate);
         });
     }
 }
コード例 #3
0
ファイル: PersistanceService.cs プロジェクト: ristica/logging
 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
ファイル: PersistanceService.cs プロジェクト: ristica/logging
 public IPersistanceData Update(IPersistanceData entityToUpdate)
 {
     using (var connection = new SqlConnectionWithExceptionLogger(this._loggingService, this._connectionStringValue))
     {
         connection.Open();
         if (entityToUpdate.PersistanceDataId == 0)
         {
             CreateStateData(connection, entityToUpdate);
         }
         else
         {
             UpdateStateData(connection, entityToUpdate);
         }
     }
     // Get from DB ? nein..ev. neue werte sind nur IDs aus output, somit alles da..
     return(entityToUpdate);
 }