我认为我不能实际上向现有的IEnumerable中添加一个字段(列)。但是我的要求是,从一个已有的IEnumerable中派生出一个新的IEnumerable,并带有一个计算字段。在WebMatrix使用Web Pages的伪代码如下:
var db = Database.Open("LOS");
var ie = db.Query(sqlAssignments);
// make a new ie2 that has an extra field
// ??? ie2 <=== ie with new field c = ie.a + ie.b
var grid = new WebGrid( ie2, extra parameters );
我知道如何在ie中循环遍历所有行,但我希望有更优雅的方法。