我有一個網格/集合對象(我們稱之爲SELECT_RESULTS),它是IList,ICollection,IEnumberable的子集。如何迭代通過ICollection並追加額外的字段
SELECT_RESULTS填充了PL/SQL SELECT存儲過程的返回結果。
我有2個問題: 1)我無法訪問SELECT_RESULTS領域在我的foreach循環,並 2)我需要添加從LINQ SELECT派生另一個字段的值到這個基於集合的主鍵上SELECT_RESULTS集合的值。
這是我到目前爲止已經試過:
// get the list of potential CUST_NAME that will be appended
var q = (from tableX in dbContext.CUSTOMER
where tableX.CUST_ID = 42
select new
{
tableX.CUST_ID
tableX.CUST_NAME
tableX.A_DATE
});
// trying to get results to know what type it's a collection of:
var results = SELECT_RESULTS as CollectionOfPeople;
// dilemma : item is an Object here, so I'm unable to access the
// different field names in the collection :-(
foreach (var item in results)
{
// question1) how to find the matching row in the collection.
// I am unable to see item.ID.
// Only can see item.ToString, item.ToHashCode, and other Object stuff
var q1 = q.Where (x => x.CUST_ID == item.ID);
// question 2) I need to Append the CUST_NAME into the collection
// onto the row having matching CUST_ID == ID
???
}