Exemplo n.º 1
0
        public virtual DriveStatistic UpdateDriveStatistic(DriveStatistic entity)
        {
            if (entity.IsTransient())
            {
                return(entity);
            }
            DriveStatistic other = GetDriveStatistic(entity.DriveStatisticId);

            if (entity.Equals(other))
            {
                return(entity);
            }
            string sql = @"Update DriveStatistic set  [IPAddress]=@IPAddress
							, [DriveSpaceAvailable]=@DriveSpaceAvailable
							, [DriveTotalSpace]=@DriveTotalSpace
							, [DriveName]=@DriveName
							, [CreationDate]=@CreationDate
							, [MachineName]=@MachineName 
							 where DriveStatisticId=@DriveStatisticId"                            ;

            SqlParameter[] parameterArray = new SqlParameter[] {
                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("@DriveName", entity.DriveName ?? (object)DBNull.Value)
                , new SqlParameter("@CreationDate", entity.CreationDate ?? (object)DBNull.Value)
                , new SqlParameter("@MachineName", entity.MachineName ?? (object)DBNull.Value)
                , new SqlParameter("@DriveStatisticId", entity.DriveStatisticId)
            };
            SqlHelper.ExecuteNonQuery(this.ConnectionString, CommandType.Text, sql, parameterArray);
            return(GetDriveStatistic(entity.DriveStatisticId));
        }
Exemplo n.º 2
0
        public virtual DriveStatistic InsertDriveStatistic(DriveStatistic entity)
        {
            DriveStatistic other = new DriveStatistic();

            other = entity;
            if (entity.IsTransient())
            {
                string         sql            = @"Insert into DriveStatistic ( [IPAddress]
				,[DriveSpaceAvailable]
				,[DriveTotalSpace]
				,[DriveName]
				,[CreationDate]
				,[MachineName] )
				Values
				( @IPAddress
				, @DriveSpaceAvailable
				, @DriveTotalSpace
				, @DriveName
				, @CreationDate
				, @MachineName );
				Select scope_identity()"                ;
                SqlParameter[] parameterArray = new SqlParameter[] {
                    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("@DriveName", entity.DriveName ?? (object)DBNull.Value)
                    , new SqlParameter("@CreationDate", entity.CreationDate ?? (object)DBNull.Value)
                    , new SqlParameter("@MachineName", entity.MachineName ?? (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(GetDriveStatistic(Convert.ToInt32(identity)));
            }
            return(entity);
        }
 public virtual DriveStatistic UpdateDriveStatistic(DriveStatistic entity)
 {
     if (entity.IsTransient()) return entity;
     DriveStatistic other = GetDriveStatistic(entity.DriveStatisticId);
     if (entity.Equals(other)) return entity;
     string sql=@"Update DriveStatistic set  [IPAddress]=@IPAddress
                     , [DriveSpaceAvailable]=@DriveSpaceAvailable
                     , [DriveTotalSpace]=@DriveTotalSpace
                     , [DriveName]=@DriveName
                     , [CreationDate]=@CreationDate
                     , [MachineName]=@MachineName
                      where DriveStatisticId=@DriveStatisticId";
     SqlParameter[] parameterArray=new SqlParameter[]{
              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("@DriveName",entity.DriveName ?? (object)DBNull.Value)
             , new SqlParameter("@CreationDate",entity.CreationDate ?? (object)DBNull.Value)
             , new SqlParameter("@MachineName",entity.MachineName ?? (object)DBNull.Value)
             , new SqlParameter("@DriveStatisticId",entity.DriveStatisticId)};
     SqlHelper.ExecuteNonQuery(this.ConnectionString,CommandType.Text,sql,parameterArray);
     return GetDriveStatistic(entity.DriveStatisticId);
 }
 public virtual DriveStatistic InsertDriveStatistic(DriveStatistic entity)
 {
     DriveStatistic other=new DriveStatistic();
     other = entity;
     if(entity.IsTransient())
     {
         string sql=@"Insert into DriveStatistic ( [IPAddress]
         ,[DriveSpaceAvailable]
         ,[DriveTotalSpace]
         ,[DriveName]
         ,[CreationDate]
         ,[MachineName] )
         Values
         ( @IPAddress
         , @DriveSpaceAvailable
         , @DriveTotalSpace
         , @DriveName
         , @CreationDate
         , @MachineName );
         Select scope_identity()";
         SqlParameter[] parameterArray=new SqlParameter[]{
              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("@DriveName",entity.DriveName ?? (object)DBNull.Value)
             , new SqlParameter("@CreationDate",entity.CreationDate ?? (object)DBNull.Value)
             , new SqlParameter("@MachineName",entity.MachineName ?? (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 GetDriveStatistic(Convert.ToInt32(identity));
     }
     return entity;
 }