public virtual PerformanceStatistic UpdatePerformanceStatistic(PerformanceStatistic entity)
        {
            if (entity.IsTransient())
            {
                return(entity);
            }
            PerformanceStatistic other = GetPerformanceStatistic(entity.PerformanceStatisticId);

            if (entity.Equals(other))
            {
                return(entity);
            }
            string sql = @"Update PerformanceStatistic set  [CPU]=@CPU
							, [Memory]=@Memory
							, [CreationDate]=@CreationDate
							, [MachineName]=@MachineName
							, [IPAddress]=@IPAddress
							, [DriveSpaceAvailable]=@DriveSpaceAvailable
							, [DriveTotalSpace]=@DriveTotalSpace 
							 where PerformanceStatisticID=@PerformanceStatisticID"                            ;

            SqlParameter[] parameterArray = new SqlParameter[] {
                new SqlParameter("@CPU", entity.Cpu ?? (object)DBNull.Value)
                , new SqlParameter("@Memory", entity.Memory ?? (object)DBNull.Value)
                , new SqlParameter("@CreationDate", entity.CreationDate ?? (object)DBNull.Value)
                , new SqlParameter("@MachineName", entity.MachineName ?? (object)DBNull.Value)
                , new SqlParameter("@IPAddress", entity.IpAddress ?? (object)DBNull.Value)
                , new SqlParameter("@DriveSpaceAvailable", entity.DriveSpaceAvailable ?? (object)DBNull.Value)
                , new SqlParameter("@DriveTotalSpace", entity.DriveTotalSpace ?? (object)DBNull.Value)
                , new SqlParameter("@PerformanceStatisticID", entity.PerformanceStatisticId)
            };
            SqlHelper.ExecuteNonQuery(this.ConnectionString, CommandType.Text, sql, parameterArray);
            return(GetPerformanceStatistic(entity.PerformanceStatisticId));
        }
        public override PerformanceStatistic InsertPerformanceStatistic(PerformanceStatistic entity)
        {
            PerformanceStatistic other = new PerformanceStatistic();

            other = entity;
            if (entity.IsTransient())
            {
                string         sql            = @"Insert into PerformanceStatistic ( [CPU],[Memory],[CreationDate],[MachineName],[IPAddress],[DriveSpaceAvailable],[DriveTotalSpace] ) Values
( @CPU, @Memory, getutcdate(), @MachineName, @IPAddress, @DriveSpaceAvailable, @DriveTotalSpace ); Select scope_identity()";
                SqlParameter[] parameterArray = new SqlParameter[] {
                    new SqlParameter("@CPU", entity.Cpu ?? (object)DBNull.Value)
                    , new SqlParameter("@Memory", entity.Memory ?? (object)DBNull.Value)
                    , new SqlParameter("@MachineName", entity.MachineName ?? (object)DBNull.Value)
                    , new SqlParameter("@IPAddress", entity.IpAddress ?? (object)DBNull.Value)
                    , new SqlParameter("@DriveSpaceAvailable", entity.DriveSpaceAvailable ?? (object)DBNull.Value)
                    , new SqlParameter("@DriveTotalSpace", entity.DriveTotalSpace ?? (object)DBNull.Value)
                };
                var identity = SqlHelper.ExecuteScalar(this.ConnectionString, CommandType.Text, sql, parameterArray);
                if (identity == DBNull.Value)
                {
                    throw new DataException("Identity column was null as a result of the insert operation.");
                }
                return(GetPerformanceStatistic(Convert.ToInt32(identity)));
            }
            return(entity);
        }
 public override PerformanceStatistic InsertPerformanceStatistic(PerformanceStatistic entity)
 {
     PerformanceStatistic other = new PerformanceStatistic();
     other = entity;
     if (entity.IsTransient())
     {
         string sql = @"Insert into PerformanceStatistic ( [CPU],[Memory],[CreationDate],[MachineName],[IPAddress],[DriveSpaceAvailable],[DriveTotalSpace] ) Values
     ( @CPU, @Memory, getutcdate(), @MachineName, @IPAddress, @DriveSpaceAvailable, @DriveTotalSpace ); Select scope_identity()";
         SqlParameter[] parameterArray = new SqlParameter[]{
              new SqlParameter("@CPU",entity.Cpu ?? (object)DBNull.Value)
             , new SqlParameter("@Memory",entity.Memory ?? (object)DBNull.Value)
             , new SqlParameter("@MachineName",entity.MachineName ?? (object)DBNull.Value)
             , new SqlParameter("@IPAddress",entity.IpAddress ?? (object)DBNull.Value)
             , new SqlParameter("@DriveSpaceAvailable",entity.DriveSpaceAvailable ?? (object)DBNull.Value)
             , new SqlParameter("@DriveTotalSpace",entity.DriveTotalSpace ?? (object)DBNull.Value)};
         var identity = SqlHelper.ExecuteScalar(this.ConnectionString, CommandType.Text, sql, parameterArray);
         if (identity == DBNull.Value) throw new DataException("Identity column was null as a result of the insert operation.");
         return GetPerformanceStatistic(Convert.ToInt32(identity));
     }
     return entity;
 }
 public virtual PerformanceStatistic UpdatePerformanceStatistic(PerformanceStatistic entity)
 {
     if (entity.IsTransient()) return entity;
     PerformanceStatistic other = GetPerformanceStatistic(entity.PerformanceStatisticId);
     if (entity.Equals(other)) return entity;
     string sql=@"Update PerformanceStatistic set  [CPU]=@CPU
                     , [Memory]=@Memory
                     , [CreationDate]=@CreationDate
                     , [MachineName]=@MachineName
                     , [IPAddress]=@IPAddress
                     , [DriveSpaceAvailable]=@DriveSpaceAvailable
                     , [DriveTotalSpace]=@DriveTotalSpace
                      where PerformanceStatisticID=@PerformanceStatisticID";
     SqlParameter[] parameterArray=new SqlParameter[]{
              new SqlParameter("@CPU",entity.Cpu ?? (object)DBNull.Value)
             , new SqlParameter("@Memory",entity.Memory ?? (object)DBNull.Value)
             , new SqlParameter("@CreationDate",entity.CreationDate ?? (object)DBNull.Value)
             , new SqlParameter("@MachineName",entity.MachineName ?? (object)DBNull.Value)
             , new SqlParameter("@IPAddress",entity.IpAddress ?? (object)DBNull.Value)
             , new SqlParameter("@DriveSpaceAvailable",entity.DriveSpaceAvailable ?? (object)DBNull.Value)
             , new SqlParameter("@DriveTotalSpace",entity.DriveTotalSpace ?? (object)DBNull.Value)
             , new SqlParameter("@PerformanceStatisticID",entity.PerformanceStatisticId)};
     SqlHelper.ExecuteNonQuery(this.ConnectionString,CommandType.Text,sql,parameterArray);
     return GetPerformanceStatistic(entity.PerformanceStatisticId);
 }