queryFromMassiveDynamic

queryFromMassiveDynamic

本文介绍了对IEnumerable< dynamic>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Rob Conery的Massive ORM。

I'm using Rob Conery's Massive ORM.

有没有一种优雅的方法来计算返回的记录集?

Is there an elegant way to do a count on the record set returned?

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++;
}


推荐答案

扩展方法成员语法,请尝试直接调用静态方法。

Rather than calling it using the extension method member syntax, try calling the static method directly.

int count = Enumerable.Count(queryFromMassiveDynamic);

这篇关于对IEnumerable< dynamic>的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-23 16:28