【发布时间】:2017-02-03 05:12:57
【问题描述】:
我现在正在生成对象列表,我需要使用字典更改具有特定 id 内部的对象列表,其中包含特定 id 对象数据。
这是我的完整代码。
m_Query = m_Query + " LEFT JOIN LIBRARY lib5 ON lib5.LIBRARY_ID = comm.STATUS2";
if (comObj.ProductsID != "" || comObj.ProductsID != null)
{
m_Query = m_Query + " where prod1.PRODUCT_ID in ";
string allproducts = string.Empty;
allproducts = comObj.ProductsID;
m_Query = m_Query + " ("+ allproducts + ") order by prod1.PRODUCT_ID desc";
}
DataSet dsPck = new DataSet();
dsPck = conn.GetDataSet(m_Query, CommandType.Text, ConnectionState.Open);
DataTable dt = new DataTable();
dt = dsPck.Tables[0];
if (dt.Rows.Count > 0)
{
for (int i = 0; i<dt.Rows.Count; i++)
{
CommitmentReport Info = new CommitmentReport();
Info.PRODUCT_ID = Convert.ToInt64(dt.Rows[i]["PRODUCT_ID"].ToString());
Info.ProductName = dt.Rows[i]["ProductName"].ToString();
Info.COMMITMENT_ID = Convert.ToInt64(dt.Rows[i]["COMMITMENT_ID"].ToString());
Info.ReferenceNo = dt.Rows[i]["ReferenceNo"].ToString();
Info.CreatedDate = Convert.ToDateTime(dt.Rows[i]["CreatedDate"].ToString());
Info.Numbers = dt.Rows[i]["Numbers"].ToString();
Info.Catalogue = dt.Rows[i]["Catalogue"].ToString();
Info.Specification = Convert.ToInt64(dt.Rows[i]["Specification"].ToString());
Info.Type = dt.Rows[i]["Type"].ToString();
Info.SubmissionType = dt.Rows[i]["SubmissionType"].ToString();
Info.ApprovalStatus = dt.Rows[i]["ApprovalStatus"].ToString();
Info.Country = dt.Rows[i]["Country"].ToString();
Info.Status = dt.Rows[i]["Status"].ToString();
// Info.Count = x;
commLst.Add(Info);
}
}
我正在返回对象列表,但现在我需要更改包含相关对象的每个特定键(PID)内部。
【问题讨论】:
-
你的问题不清楚。您到底在寻找什么?样本输入/输出?
-
需要将我的对象列表更改为字典键列表
-
输入是多个 PID。需要输出的列表是: PID1:相关对象。 PID2:相关对象等
-
所以你是说有相同
PRODUCT_ID的项目,你想按他们的PRODUCT_ID分组? -
是的。正确的 。我需要的输出是这样的。
标签: c# asp.net dictionary