我有以下類無法隱式轉換型「的IEnumerable <ob>」到「Generic.List <cdsworkflows>」嵌套對象
public class cdsworkflows
{
public string WorkflowName;
public string ActionGroup;
}
public class cdssystems
{
public string cdsSystemName;
public List<cdsmodules> listModules;
}
public class cdsmodules
{
public string moduleName;
public List<cdsworkflows> listWorkflows;
}
我推值,以上述對象從一個表中的所有這些數據如下。我在收到錯誤「選擇新的」中指出:
Cannot implicitly convert type
System.Collections.Generic.IEnumerable<cdsworkflows>
toSystem.Collections.Generic.List<cdsworkflows>
. An explicit conversion exists (are you missing a cast?)
此外,如果你看到最後一行ActionGroup = grpWorkflows.Count().ToString()
我想要分配的價值,而不是數量。怎麼做。
List<cdssystems> results =
(from SPListItem item in myItemsList
group item by item["Systems"]
into grp
select new cdssystems()
{
cdsSystemName = grp.Key.ToString(),
listModules =
from item in grp
group item by item["Modules"]
into grpModules
select new cdsmodules()
{
moduleName = grpModules.Key.ToString(),
listWorkflows =
from item in grpModules
group item by item["Workflows"]
into grpWorkflows
select new cdsworkflows()
{
WorkflowName = grpWorkflows.Key.ToString(),
ActionGroup = grpWorkflows.Count().ToString()
}
}
}
).ToList();
你是什麼意思*我想分配的價值,而不是計數。怎麼做。*? –
其實我在物品[「ActionGroup」]中收集。那基本上是葉節點。我想將該值分配給ActionGroup。 –
查看下面更新回答 –