返回数据类型

时间:2011-05-12 06:04:11

标签: c# database silverlight wcf service

任何人都可以帮我识别返回数据类型是这组代码???

[OperationContract]
        public List<PrimaryClass> getPrimaryList()
        {
            string priConn = System.Configuration.ConfigurationManager.ConnectionStrings["SchoolConnectionString"].ConnectionString;
            var priList = new List<PrimaryClass>();
            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;

                }

            }
        }

1 个答案:

答案 0 :(得分:1)

这会返回List<>PrimaryClass个类,设置PrimarySchoolTopHonourCcaTopStudentTopAggregate ,每个TopImage属性。