【发布时间】:2018-09-27 18:36:49
【问题描述】:
如果您希望获得带有 Acl 类的 IDS 的列表,问题是这些都包含在以下公司列表中...
公司:CS
public class Company
{
[JsonProperty(PropertyName = "id")]
public int Id { get; set; }
[JsonProperty(PropertyName = "name")]
public string Name { get; set; }
[JsonProperty(PropertyName = "acl")]
public List<Acl> Acl { get; set; }
}
ACL.CS:
public class Acl
{
[JsonProperty(PropertyName = "id")]
public int Id { get; set; }
[JsonProperty(PropertyName = "name")]
public string Name { get; set; }
[JsonProperty(PropertyName = "actions")]
public List<Action> Actions { get; set; }
}
这些对象是 JSON 类型,具有以下结构
图像显示了您想要获取的示例,包含 COMPANY 的 ACL 对象的 IDS 列表
但是我怎样才能得到这个结果呢?我目前有以下查询
var servicios = mainViewModel.LoginResponse.Companies
.Where(c => c.Principal == true)
.Select(c => c.Acl)
.ToList();
如何隔离我的对象并仅获取所需 IDS 的列表?我必须使用什么 LINQ 命令?对我有什么帮助吗?
【问题讨论】:
标签: c# list performance linq linq-to-sql