title: How to populate C# list and perform multiplication between items in the list and some value riched by SQL procedure
body: <p>I would ask for some help related my problem.</p>
  
  <p>I need to calculate in C# according to formula :</p>
  
  <p>(Ra,p -RavgA)
  Where :</p>
  
  <ol>
  <li>Ra,p is "rating of user a for item p" and</li>
  <li>RavgA is "user's average rating"</li>
  </ol>
  
  <p>To reach data "rating of users a for item p" I'm using SQL stored procedure:</p>
  
  <pre><code>SELECT     Ocjena_ID
  </code></pre>
  
  <p>FROM         OcjeneKorisnika
  WHERE     (Korisnik_ID = @Korisnik_ID)</p>
  
  <p>For example, this stored procedure give me values for "Ocjena_ID" :</p>
  
  <ol>
  <li>4</li>
  <li>5</li>
  <li>5</li>
  </ol>
  
  <p>To populate list in C#, in DBBL I have defined :</p>
  
  <pre><code>public List&lt;SelectOcjeneZaDoSadaOcjenjeneArtikleSP_Result&gt; SelectOcjeneZaDoSadaOcjenjeneArtikleSP(int Korisnik_ID)
      {
          return context.SelectOcjeneZaDoSadaOcjenjeneArtikleSP(Korisnik_ID).ToList();
  
      }
  </code></pre>
  
  <p>For calculation of "user's average rating", I'm using in CB :</p>
  
  <pre><code>string connectionString = "Data Source=localhost;Initial Catalog=OnLineTeaShop;Trusted_Connection=True;";
              using (SqlConnection conn = new SqlConnection(connectionString))
              {
                  using (SqlCommand cmd = new SqlCommand("dbo.AVG_Evaluation_for_CustomerV2SP"))
                  {
                      cmd.CommandType = CommandType.StoredProcedure;
                      cmd.Parameters.Add(new SqlParameter("@Korisnik_ID", Convert.ToInt32(Session["UserID"])));
  
                      SqlParameter countParameter = new SqlParameter("@retAVGVal", SqlDbType.Float);
                      countParameter.Direction = ParameterDirection.Output;
                      cmd.Parameters.Add(countParameter);
  
                      conn.Open();
                      cmd.Connection = conn;
  
                      cmd.ExecuteNonQuery();
                      string SrednjaVrijednost = cmd.Parameters["@retAVGVal"].Value.ToString();
  
  
                      txtAktvniAVG.Text = SrednjaVrijednost;
  
  
                      conn.Close();
                  }
  
              }
  </code></pre>
  
  <p>This code give me in txtAktivniAVG field value 4,67.</p>
  
  <p>Question is how to reach data from the list in CB file and calculate multiplication for each items in list with value reached for "user's average rating", and create/populate matrix which need to have 1 row and i ( in this case 3) columns with those data ? </p>
  
  <p>Thank you in advance on support.</p>
  
  <p>BR,</p>
  
  <p>Damir</p>