queryFromMassiveDynamic

queryFromMassiveDynamic

我正在使用Rob Conery的Massive ORM。

有没有一种优雅的方法可以对返回的记录集进行计数?

dynamic viewModelExpando = result.ViewData.Model;
var queryFromMassiveDynamic = viewModelExpando.TenTricksNewestFirst;

//fails as have actually got TryInvokeMember on it
var z = queryFromMassiveDynamic.Count();

//works
int i = 0;
foreach (var item in queryFromMassiveDynamic) {
    i++;
}

最佳答案

不要尝试使用扩展方法成员语法来调用它,而是尝试直接调用静态方法。

int count = Enumerable.Count(queryFromMassiveDynamic);

08-17 00:15