关于IList、IQueryable、IEnumerable与Func、Expression的关系
2016-03-03 19:36
471 查看
关于IList、IQueryable、IEnumerable与Func、Expression的关系
session是NHibernate中的ISession对象
IList、IQueryable、 IEnumerable是.NET对象
Func和Expression是C#3.0中的Linq类库中的二个对象
Func:函数,也可称做委托。
Expression:表达式。
以下是这篇文章中用到的三个数据操作的核心对象:
seeion.CreateCriteria, Queryable, Enumerable
通过 以上代码我们可以得知:
session接受func参数
Queryable接受expression参数
Enumerable接受func参数
版权所有,转载请注明文章出处 http://blog/csdn.net/cadenzasolo
session是NHibernate中的ISession对象
IList、IQueryable、 IEnumerable是.NET对象
Func和Expression是C#3.0中的Linq类库中的二个对象
Func:函数,也可称做委托。
Expression:表达式。
以下是这篇文章中用到的三个数据操作的核心对象:
seeion.CreateCriteria, Queryable, Enumerable
seeion.CreateCriteria -> Func<T, bool> Queryable -> Expression<Func<T, bool>> -> Linq to sql Enumerable -> Func<T, bool> -> Linq to object Func = Expression.Compile Expression = ex => Func(ex) //没有func或expression的函数,也就是没有where(predicate)条件的函数 //3个返回IList<T>类型的函数IList<T> List() IList seeion.CreateCriteria no func/no expression 有意义( IList Queryable where=t=>true no func/no expression 无意义 IList Enumerable where=t=>true no func/no expression 无意义 //3个IQueryable<T> List() IQueryable seeion.CreateCriteria no func/no expression 有意义 IQueryable Queryable where=t=>true no func/no expression 无意义 IQueryable Enumerable where=t=>true no func/no expression 无意义 3个IEnumerable<T> List() IEnumerable seeion.CreateCriteria no func/no expression 有意义 IEnumerable Queryable where=t=>true no func/no expression 无意义 IEnumerable Enumerable where=t=>true no func/no expression 无意义 //有func或expression的函数,也就是有where(predicate)条件的函数 //6个返回IList<T>类型的函数IList<T> List(func/expr) Speed IList where func 1first IList where.compile() expression 3third IList Queryable ex => where(ex) func 4worst IList Queryable where expression 2second IList Enumerable where func 1first IList Enumerable where.compile()expression 3third //6个返回IQueryable<T>的函数 IQueryable where func IQueryable where.compile() expression IQueryable Queryable ex => where(ex) func IQueryable Queryable where expression IQueryable Enumerable where func IQueryable Enumerable where.compile() expression //6个返回IEnumerable<T>的函数 IEnumerable where func IEnumerable where.compile() expression IEnumerable Queryable where expression IEnumerable Queryable ex => where(ex) func IEnumerable Enumerable where.compile() expression IEnumerable Enumerable where func
以上代码通过筛选后得到6个方法 1.IList where func 2.IList where.compile() expression 3.IQueryable Queryable ex => where(ex) func 4.IQueryable Queryable where expression 5.IEnumerable Enumerable where.compile() expression 6.IEnumerable Enumerable where func 第一:1和6效率最高, func(从函数到函数) 第二:然后是4次之, expression(从表达式到表达式) 第三:2和5第三, 表达式编译(从表达式到函数) 第四:3是最慢的, 表达式代入函数(从函数到表达式)
通过 以上代码我们可以得知:
session接受func参数
Queryable接受expression参数
Enumerable接受func参数
版权所有,转载请注明文章出处 http://blog/csdn.net/cadenzasolo
相关文章推荐
- NET IIS暴绝对路径漏洞
- NET LOCALGROUP命令详解(将用户添加到管理员组等)
- NET USER 命令详解(dos下添加用户)
- cpan安装Net::SSH::Perl中遇到的一些问题
- 不要使用CSS Expression的原因分析
- SQL 查询分析中使用net命令问题
- 表格隔行换色 css expression
- Expression Web 2006正式发布
- .Net 项目代码风格要求小结
- 用 Net 命令使局域网文件批量同步更新
- javascript中expression的用法整理
- 一步步教你读懂NET中IL(图文详解)
- 使用.NET中的Action及Func泛型委托深入剖析
- NET Runtime Optimization Service 1101 错误的解决方法
- (翻译)Java SE 8 Lambda 特性与基本原理(上)
- KVM网络性能测试(3)
- C#.net数据库访问及其操作类
- NET::SMTP
- new 和 alloc init的区别
- System.Net.Mail with SSL to authenticate against port 465