从字典中获取所有值
get all values from dictionary
我在我的网站上使用了 linqjs,我正在尝试获取一个字典的所有值,其中包含 toDictionary()
库扩展。
这是我的代码:
var imagesDictionary = Enumerable.from(data)
.select(function (x) {
var images = Enumerable.from(x.ImagesSections)
.selectMany(function (y) {
return Enumerable.from(y.Images)
.select(function (z) {
return z.Thumb;
});
})
.toArray();
return { Title: x.Title, Images: images };
})
.toDictionary("$.Title", "$.Images");
var imagesToPreload = imagesDictionary.toEnumerable()
.selectMany("$.Value");
我希望 imagesToPreload 成为字典中包含的所有图像的数组,但我不明白该怎么做:
var imagesToPreload = imagesDictionary.toEnumerable()
.selectMany("$.Value");
似乎比每个人以前获得的方式都好。
有人可以帮我吗?
由于您使用的是 linqjs 3 beta 版本,因此条目的格式已更改。这些属性现在是小写的。
var imagesDictionary = Enumerable.from(data)
.toDictionary("$.Title",
"Enumerable.from($.ImagesSections).selectMany('$.Images', '$$.Thumb').toArray()"
);
var imagesToPreload = imagesDictionary.toEnumerable()
.selectMany("$.value") // lowercase 'value'
.toArray();
我在我的网站上使用了 linqjs,我正在尝试获取一个字典的所有值,其中包含 toDictionary()
库扩展。
这是我的代码:
var imagesDictionary = Enumerable.from(data)
.select(function (x) {
var images = Enumerable.from(x.ImagesSections)
.selectMany(function (y) {
return Enumerable.from(y.Images)
.select(function (z) {
return z.Thumb;
});
})
.toArray();
return { Title: x.Title, Images: images };
})
.toDictionary("$.Title", "$.Images");
var imagesToPreload = imagesDictionary.toEnumerable()
.selectMany("$.Value");
我希望 imagesToPreload 成为字典中包含的所有图像的数组,但我不明白该怎么做:
var imagesToPreload = imagesDictionary.toEnumerable()
.selectMany("$.Value");
似乎比每个人以前获得的方式都好。
有人可以帮我吗?
由于您使用的是 linqjs 3 beta 版本,因此条目的格式已更改。这些属性现在是小写的。
var imagesDictionary = Enumerable.from(data)
.toDictionary("$.Title",
"Enumerable.from($.ImagesSections).selectMany('$.Images', '$$.Thumb').toArray()"
);
var imagesToPreload = imagesDictionary.toEnumerable()
.selectMany("$.value") // lowercase 'value'
.toArray();