我正在学习 LINQ,我想使用 LINQ 找到第三个最高薪水。我知道如何查询集合,但我不知道如何解决这个问题
void Main()
{
List<Employee> employees = new List<Employee>();
employees.Add(new Employee { Id = 1, Name = "John Doe", Salary = 1500 });
employees.Add(new Employee { Id = 1, Name = "John Wow", Salary = 10000 });
employees.Add(new Employee { Id = 1, Name = "Bill", Salary = 1000 });
employees.Add(new Employee { Id = 1, Name = "Jane Doe", Salary = 2000 });
var secondHighestSalary=from e in employees
select e ----
}
public class Employee
{ …
Run Code Online (Sandbox Code Playgroud) 我在猫鼬中有以下模型,其中博客有很多评论
var mongoose = require('mongoose')
, Schema = mongoose.Schema
var blogScheam = Schema({
title: String,
comments: [{ type: Schema.Types.ObjectId, ref: 'Comment' }]
});
module.exports = mongoose.model('Post', blogScheam);
Run Code Online (Sandbox Code Playgroud)
评论模型
var mongoose = require('mongoose')
, Schema = mongoose.Schema
var commentSchema = Schema({
comment: String,
user: { type: Schema.Types.ObjectId, ref: 'User' }
});
module.exports = mongoose.model('Comment', commentSchema);
Run Code Online (Sandbox Code Playgroud)
用户模式
var mongoose = require('mongoose')
, Schema = mongoose.Schema
var userScheam = Schema({
name: String,
age: Number,
posts: [{ type: Schema.Types.ObjectId, ref: 'Post' }]
});
module.exports …
Run Code Online (Sandbox Code Playgroud) 我的api在一个http调用中返回20个结果,但我想要40个记录同样我正在进行嵌套的http调用,如下所示.我能够获取40个记录,但是当我订阅getALl()方法时,我只得到20个结果;
getAll() {
return this._http.get(this.baseURL)
.do((data: any) => {
this.nextPage = data.next_page_token;
var results = data.results;
return this._http.get(`${this.baseURL}?next=${this.nextPage}`).delay(2000).do((d: any) => {
return Observable.of(results.concat(d.results));
});
});
}
Run Code Online (Sandbox Code Playgroud)