我正在尝试的是以下内容:
public class AHME
{
public string elementName { get; set; }
public long? elementID { get; set; }
public AHME[] children { get; set; }
public static AHME[] GetAHME()
{
var listS = new List<AHME>();
using (var db = new DBEntities())
{
AHME sList = db.Stnd.Select(s => new AHME
{
elementID = s.ID,
elementName = s.Name,
}).ToList();
listS.Add(sList);
var listT = new List<AHME>();
using (var db = new DBEntities())
{
AHME tList = db.Tr.Join(db.Us, t => t.ID, u => u.ID, (t, u) => new AHME
{
elementID = t.ID,
elementName = u.FirstNames + " " + u.LastName,
children=listS.ToArray(),
});
listT.Add(tList).ToList();
}
return listT.ToArray();
}
}
}
但我收到如下错误:
无法将类型“
System.Collections.Generic.List<LSB.HM.AHME>
”隐式转换为“LSB.HM.AHME
”无法将类型“
System.Linq.IQueryable<LSB.HM.AHME>
”隐式转换为“LSB.HM.AHME
”。存在显式转换(您是否缺少演员表?)
此外,对于“ AHME sList
”,如果我可以使用 var 类型var sList
,那么它的抛出错误是:
<LSB.HM.AHME>.Add
有一些无效的论点