文/www.codeplex.com/JSLINQ 译/worksguo 出处/博客园
LINQ to JavaScript是使用JavaScript来做出类似LINQ样的功能,可以做到在客户端对一些数据筛选,加强了对数组的操作.其中有一些功能本来JavaScript就有如对数组数据过滤的功能,再想想就这样筛选数据没有什么大的意义,但要把筛选后的数据又通过JSON反回到服务端那就有用拉.这样可以和Silverlight1.0,asp.net ajax在一起使用,它能对他们起到一定的辅助作用吧.(还有这个只能对数组中使用)
--------------------------------------------------------------------------------
资料:
--------------------------------------------------------------------------------
http://www.nikhilk.net/ScriptAndLINQ.aspxhttp://pietschsoft.com/post/2008/01/LINQ-to-JavaScript-(JSLINQ)-Open-Source-Project-Launched!.aspxhttp://www.codeplex.com/JSLINQ--------------------------------------------------------------------------------
一:介绍--------------------------------------------------------------------------------
LINQ to JavaScript(JSLINQ)是一个LINQ to Object在 javaScript中的实现,它对JavaScript Arrary Objcet构建一些列的扩展方法.如果你使用一个Array,你能使用LINQ to JavaScript.
现在的发布版本是是1.03支持
Operators
- From
- Where
- OrderBy
- Select
Added the OrderByDescending Operator
- Added the SelectMany Operator
- Added the Count Operator
- Added the Distinct Operator
- Added the Any Operator
- Added the All Operator
- Made it so you can access the elements "index" within the clause/predicate of each of the following Operators: Where, Count, Any, All
- Added the Reverse Operator, this also allows access to the elements "index" within the clause/predicate
- Added First Operator, this also allows access to the elements "index" within the clause/predicate
- Added Last Operator, this also allows access to the elements "index" within the clause/predicate
- Added ElementAt Operator
- Added Concat Operator - this is identical to JavaScripts Array.concat method
Intersect Operator
- Added DefaultIfEmpty Operator
- Added ElementAtOrDefault Operator
- Added FirstOrDefault Operator
- Added LastOrDefault Operator
- Unit Test Created
--- Intial testing of the Samples Unit Tests yielded the following speed results for all tests:
------ IE7: ~10 milliseconds
------ FireFox 2: ~10 milliseconds
------ Safari 3 for Windows: ~4 milliseconds
使用
(1)在你的工程中添加JSLINQ.js文件;
(2)在你的页面中添上代码<script type="text/javascript" src="JS/JSLINQ.js"></script>
您可能对 [javascript] 的这些文章也感兴趣: