如何将Func与返回IOrderedQueryable的IQueryable一起使用 [英] How to use Func with IQueryable that returns IOrderedQueryable
本文介绍了如何将Func与返回IOrderedQueryable的IQueryable一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在做一些关于EF的研究,并且遇到了一个可以接受的功能
I'm doing some research about EF and came across a function that accepts
Func<IQueryable<Student>, IOrderedQueryable<Student>>
,只是想知道如何调用接受此类参数的函数?
and just wondering how to call that function that accepts that kind of parameter?
推荐答案
想象函数就是这样,您在Student类中有一个属性ID.
imagine function is something like that, and you've got a property Id in Student class.
public static class Helper {
public static void Test(Func<IQueryable<Student>, IOrderedQueryable<Student>> param)
{
var test = 0;
}
}
那么您可以通过这种方式使用它
then you could use it this way
var student = new List<Student>().AsQueryable();//non sense, just for example
Helper.Test(m => student.OrderBy(x => x.Id));
m => student.OrderBy(x => x.Id)
是一个
Func<IQueryable<Student>, IOrderedQueryable<Student>>
(IQueryable<student>
作为参数,返回IOrderedQueryable<Student>
)
或者只是
Helper.Test(m => m.OrderBy(x => x.Id));
实际上,没有真实"功能并没有多大意义...
In fact this doesn't make much sense without a "real" function...
这篇关于如何将Func与返回IOrderedQueryable的IQueryable一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文