title: Calling a wcf service method from Silverlight
body: <p>I need to call a wcf service method in my project, if I have a method called getPrimaryList, how do I call it?</p>
  
  <pre><code>[OperationContract]
          public List&lt;PrimaryClass&gt; getPrimaryList()
          {
              string priConn = System.Configuration.ConfigurationManager.ConnectionStrings["SchoolConnectionString"].ConnectionString;
              var priList = new List&lt;PrimaryClass&gt;();
              using (SqlConnection conn = new SqlConnection(priConn))
              {
                  const string sql = @"SELECT PrimarySchool,TopHonour,Cca,TopStudent,TopAggregate,TopImage FROM [Primary]";
                  conn.Open();
                  using (SqlCommand cmd = new SqlCommand(sql, conn))
                  {
                      SqlDataReader dr = cmd.ExecuteReader(
                          CommandBehavior.CloseConnection);
                      if (dr != null)
                          while (dr.Read())
                          {
                              var pri = new PrimaryClass
                              {
                                  PrimarySchool = dr.GetString(0),
                                  TopHonour = dr.GetString(1),
                                  Cca = dr.GetString(2),
                                  TopStudent = dr.GetString(3),
                                  TopAggregate = dr.GetString(4),
                                  TopImage = dr.GetString(5)
                              };
                              priList.Add(pri);
                          }
                      return priList;
  
                  }
  
              }
          }
  </code></pre>