linqjs试用

Posted yzd

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linqjs试用相关的知识,希望对你有一定的参考价值。

 1 var data = {
 2     customers: [{
 3         id: 1,
 4         firstname: ‘John‘,
 5         lastname: ‘Smith‘,
 6         sex: ‘male‘
 7     }, {
 8         id: 2,
 9         firstname: ‘Jessica‘,
10         lastname: ‘Johnson‘,
11         sex: ‘female‘
12     }, {
13         id: 3,
14         firstname: ‘Michael‘,
15         lastname: ‘Williams‘,
16         sex: ‘male‘
17     }, {
18         id: 4,
19         firstname: ‘Amber‘,
20         lastname: ‘Davis‘,
21         sex: ‘female‘
22     }],
23     address: [{
24         id: 1,
25         address: ‘ynkm‘
26     }, {
27         id: 2,
28         address: ‘ynyx‘
29     }]
30 };
31 
32 var enumerable=Enumerable.from(data.customers);
33 
34 enumerable.groupBy("$.firstname.charAt(0)", "x=>x.firstname").forEach(function(group) {
35     console.log(group.key());
36     group.forEach(function(aaa) {
37         console.log(aaa);
38     });
39 });
40 
41 
42 enumerable.groupBy("$.firstname.charAt(0)",  "","key,group=>key+‘-‘+group.select(‘$.firstname‘).toJoinedString(‘,‘)").forEach(function(group) {
43     console.log(group);
44 });
45 
46 enumerable.toLookup("$.sex","$.firstname").toEnumerable().forEach(function(group) {
47     console.log(group.key());
48     group.orderBy().forEach(function(aaa) {
49         console.log(aaa);
50     });
51 });
52 
53 console.log(enumerable.toDictionary("$.firstname").get("Richard"));
54 console.log(enumerable.toObject("$.firstname")["Richard"]);
55 
56 var enumerable2=Enumerable.from(data.address);
57 //inner join
58 enumerable.join(enumerable2, "$.id", "$.id", "outer,inner=>{‘id‘:outer.id,‘firstname‘:outer.firstname,‘address‘:inner.address}").forEach(function(aaa) {
59     console.log(aaa);
60 });
61 
62 enumerable.groupJoin(enumerable2, "$.id", "$.id", "outer,inner=>{‘id‘:outer.id,‘firstname‘:outer.firstname,‘address‘:inner&&inner.address||‘‘}").forEach(function(aaa) {
63     console.log(aaa);
64 });

 

以上是关于linqjs试用的主要内容,如果未能解决你的问题,请参考以下文章

Android 片段复制

选项卡颜色变化

Jquery.Linq用法

代码审查RhodeCode试用

ChatGPT国内镜像站试用,聊天Python代码生成。

原创单测代码生成工具Evosuite试用