我有以下JSON
[
{
"id": 1,
"firstName": "Smith",
"lastName": "Bill",
"emails": [
{
"id": 1,
"email": "Bill@Smith.Com",
"dateCreated": "2017-05-11T10:18:52.3224545-07:00"
},
{
"id": 2,
"email": "Bill@gmail.com",
"dateCreated": "2017-05-11T10:20:05.9283127-07:00"
}
]
},
{
"id": 2,
"firstName": "Bill",
"lastName": "Smith",
"emails": []
}
]
电子邮件模型对象位于此人内部。
我想知道如何使用LINQ语句返回所有拥有与某些输入相匹配的电子邮件的人。例如,如果我搜索" Bill@gmail.com" ;,它只会返回
[
{
"id": 1,
"firstName": "Smith",
"lastName": "Bill",
"emails": [
{
"id": 1,
"email": "Bill@Smith.Com",
"dateCreated": "2017-05-11T10:18:52.3224545-07:00"
},
{
"id": 2,
"email": "Bill@gmail.com",
"dateCreated": "2017-05-11T10:20:05.9283127-07:00"
}
]
}
]
应该看起来像下面的内容?
var personWithEmail = People.FirstOrDefault(e => e.Id == i);
除了这只是找到有ID的人,而我想深入查看他们孩子的电子邮件并搜索电子邮件是否匹配。