任何人都可以帮我识别返回数据类型是这组代码???
[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;
}
}
}
答案 0 :(得分:1)
这会返回List<>
个PrimaryClass
个类,设置PrimarySchool
,TopHonour
,Cca
,TopStudent
,TopAggregate
,每个TopImage
属性。