本文整理匯總了C#中WebApplication1.List.Concat方法的典型用法代碼示例。如果您正苦於以下問題:C# List.Concat方法的具體用法?C# List.Concat怎麽用?C# List.Concat使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類WebApplication1.List
的用法示例。
在下文中一共展示了List.Concat方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: fillDegreeInfo
//fills in degree info from server, stores data in global vars
protected void fillDegreeInfo()
{
//clear previous data
ReqIDNumberNeeded = new Dictionary<int, int>();
ReqIDClassesNeeded = new Dictionary<int, List<string>>();
introReqID = new List<int>();
mainReqID = new List<int>();
introNeeded = false;
SqlDataReader rdr;
//queries tbl_opt_req_relationship for all reqIDs for selected degree option
string sql = "SELECT ReqID, IsIntroductory FROM wi.tbl_opt_req_relationship " +
"WHERE OptionID = " + ddlOption.SelectedValue.ToString();
MyConnection.Open();
SqlCommand cmd = new SqlCommand(sql, MyConnection);
rdr = cmd.ExecuteReader();
while (rdr.Read())
{
int ReqID = Convert.ToInt32(rdr.GetValue(0));
bool isIntro = Convert.ToBoolean(rdr.GetValue(1));
if (isIntro)
{
introNeeded = true;
introReqID.Add(ReqID);
} else
{
mainReqID.Add(ReqID);
}
}
rdr.Close();
MyConnection.Close();
//queries tbl_requirement number of classes needed for each reqID
foreach (int ReqID in introReqID.Concat(mainReqID))
{
sql = "SELECT NumRequired FROM wi.tbl_requirement " +
"WHERE ReqID = @ReqID;";
cmd = new SqlCommand(sql, MyConnection);
cmd.Parameters.Add("@ReqID", System.Data.SqlDbType.VarChar);
cmd.Parameters["@ReqID"].Value = ReqID;
MyConnection.Open();
rdr = cmd.ExecuteReader();
while (rdr.Read())
{
ReqIDNumberNeeded[ReqID] = Convert.ToInt32(rdr.GetValue(0));
}
rdr.Close();
MyConnection.Close();
//ensures ReqID entries with an empty list exist in ReqIdClassesNeeded
ReqIDClassesNeeded[ReqID] = new List<string>();
}
//queries tbl_req_course_relationship and loads all classes with same ReqID into Dictionary
foreach (int ReqID in introReqID.Concat(mainReqID))
{
sql = "SELECT CourseNumber FROM wi.tbl_req_course_relationship " +
"WHERE ReqID = @ReqID;";
cmd = new SqlCommand(sql, MyConnection);
cmd.Parameters.Add("@ReqID", System.Data.SqlDbType.VarChar);
cmd.Parameters["@ReqID"].Value = ReqID;
MyConnection.Open();
rdr = cmd.ExecuteReader();
while (rdr.Read())
{
//adds each class for given ReqID
ReqIDClassesNeeded[ReqID].Add(rdr.GetValue(0).ToString());
}
rdr.Close();
MyConnection.Close();
}
MyConnection.Close();
//allows you to make sure classes are actually added
/*
foreach (int ReqID in introReqID.Concat(mainReqID))
{
resultsBox.Items.Add(new ListItem(ReqID.ToString(), "alal"));
foreach(string cl in ReqIDClassesNeeded[ReqID])
{
resultsBox.Items.Add(new ListItem(cl, cl));
}
}
*/
}