public override NetworkStatistic InsertNetworkStatistic(NetworkStatistic entity)
        {
            NetworkStatistic other = new NetworkStatistic();

            other = entity;
            if (entity.IsTransient())
            {
                string         sql            = @"Insert into NetworkStatistic ( [InterfaceName]
				,[IPAddress]
				,[TotalUsage]
				,[Download]
				,[Upload]
				,[CreationDate]
				,[ServerIp]
				,[ServerName] )
				Values
				( @InterfaceName
				, @IPAddress
				, @TotalUsage
				, @Download
				, @Upload
				, @CreationDate
				, @ServerIp
				, @ServerName );
				Select scope_identity()"                ;
                SqlParameter[] parameterArray = new SqlParameter[] {
                    new SqlParameter("@InterfaceName", entity.InterfaceName)
                    , new SqlParameter("@IPAddress", entity.IpAddress)
                    , new SqlParameter("@TotalUsage", entity.TotalUsage)
                    , new SqlParameter("@Download", entity.Download)
                    , new SqlParameter("@Upload", entity.Upload)
                    , new SqlParameter("@CreationDate", entity.CreationDate)
                    , new SqlParameter("@ServerIp", entity.ServerIp ?? (object)DBNull.Value)
                    , new SqlParameter("@ServerName", entity.ServerName ?? (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(GetNetworkStatistic(Convert.ToInt32(identity)));
            }
            return(entity);
        }
 public override NetworkStatistic InsertNetworkStatistic(NetworkStatistic entity)
 {
     NetworkStatistic other = new NetworkStatistic();
     other = entity;
     if (entity.IsTransient())
     {
         string sql = @"Insert into NetworkStatistic ( [InterfaceName]
         ,[IPAddress]
         ,[TotalUsage]
         ,[Download]
         ,[Upload]
         ,[CreationDate]
         ,[ServerIp]
         ,[ServerName] )
         Values
         ( @InterfaceName
         , @IPAddress
         , @TotalUsage
         , @Download
         , @Upload
         , @CreationDate
         , @ServerIp
         , @ServerName );
         Select scope_identity()";
         SqlParameter[] parameterArray = new SqlParameter[]{
              new SqlParameter("@InterfaceName",entity.InterfaceName)
             , new SqlParameter("@IPAddress",entity.IpAddress)
             , new SqlParameter("@TotalUsage",entity.TotalUsage)
             , new SqlParameter("@Download",entity.Download)
             , new SqlParameter("@Upload",entity.Upload)
             , new SqlParameter("@CreationDate",entity.CreationDate)
             , new SqlParameter("@ServerIp",entity.ServerIp ?? (object)DBNull.Value)
             , new SqlParameter("@ServerName",entity.ServerName ?? (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 GetNetworkStatistic(Convert.ToInt32(identity));
     }
     return entity;
 }
        public virtual NetworkStatistic UpdateNetworkStatistic(NetworkStatistic entity)
        {
            if (entity.IsTransient())
            {
                return(entity);
            }
            NetworkStatistic other = GetNetworkStatistic(entity.NetworkStatisticId);

            if (entity.Equals(other))
            {
                return(entity);
            }
            string sql = @"Update NetworkStatistic set  [InterfaceName]=@InterfaceName
							, [IPAddress]=@IPAddress
							, [TotalUsage]=@TotalUsage
							, [Download]=@Download
							, [Upload]=@Upload
							, [CreationDate]=@CreationDate
							, [ServerIp]=@ServerIp
							, [ServerName]=@ServerName 
							 where NetworkStatisticId=@NetworkStatisticId"                            ;

            SqlParameter[] parameterArray = new SqlParameter[] {
                new SqlParameter("@InterfaceName", entity.InterfaceName)
                , new SqlParameter("@IPAddress", entity.IpAddress)
                , new SqlParameter("@TotalUsage", entity.TotalUsage)
                , new SqlParameter("@Download", entity.Download)
                , new SqlParameter("@Upload", entity.Upload)
                , new SqlParameter("@CreationDate", entity.CreationDate)
                , new SqlParameter("@ServerIp", entity.ServerIp ?? (object)DBNull.Value)
                , new SqlParameter("@ServerName", entity.ServerName ?? (object)DBNull.Value)
                , new SqlParameter("@NetworkStatisticId", entity.NetworkStatisticId)
            };
            SqlHelper.ExecuteNonQuery(this.ConnectionString, CommandType.Text, sql, parameterArray);
            return(GetNetworkStatistic(entity.NetworkStatisticId));
        }
 public virtual NetworkStatistic UpdateNetworkStatistic(NetworkStatistic entity)
 {
     if (entity.IsTransient()) return entity;
     NetworkStatistic other = GetNetworkStatistic(entity.NetworkStatisticId);
     if (entity.Equals(other)) return entity;
     string sql=@"Update NetworkStatistic set  [InterfaceName]=@InterfaceName
                     , [IPAddress]=@IPAddress
                     , [TotalUsage]=@TotalUsage
                     , [Download]=@Download
                     , [Upload]=@Upload
                     , [CreationDate]=@CreationDate
                     , [ServerIp]=@ServerIp
                     , [ServerName]=@ServerName
                      where NetworkStatisticId=@NetworkStatisticId";
     SqlParameter[] parameterArray=new SqlParameter[]{
              new SqlParameter("@InterfaceName",entity.InterfaceName)
             , new SqlParameter("@IPAddress",entity.IpAddress)
             , new SqlParameter("@TotalUsage",entity.TotalUsage)
             , new SqlParameter("@Download",entity.Download)
             , new SqlParameter("@Upload",entity.Upload)
             , new SqlParameter("@CreationDate",entity.CreationDate)
             , new SqlParameter("@ServerIp",entity.ServerIp ?? (object)DBNull.Value)
             , new SqlParameter("@ServerName",entity.ServerName ?? (object)DBNull.Value)
             , new SqlParameter("@NetworkStatisticId",entity.NetworkStatisticId)};
     SqlHelper.ExecuteNonQuery(this.ConnectionString,CommandType.Text,sql,parameterArray);
     return GetNetworkStatistic(entity.NetworkStatisticId);
 }