从我有这个 linq 查询来从 IQueryable 构建一个 json(字符串和布尔值?):
var ret = from c in results select new { country = c.EN, schengen = c.Schengen };
我想手动添加新项目:(伪代码)
ret = ret /* add this -> */ { country = "some new country", schengen = true }
我试过这样做:
//End up with cannot convert from AnonymousType#2 to AnonymousType#1
var listRet = ret.ToList();
listRet.Add(new { country ="", schengen = true });
由于它是我构建的匿名类型,我找不到添加它的方法。我总是以转换错误告终