【发布时间】:2022-01-22 01:32:24
【问题描述】:
如你所见,我有这个模型:
public class UserNotes : BaseEntity
{
public IList<SymbolNotes> SymbolsNotes { get; set; }
public UserNotes(string userId): base($"UserNotes/{userId}")
{
}
}
public class SymbolNotes
{
public string Isin { get; set; }
public List<NoteItem> Notes { get; set; }
}
【问题讨论】:
-
因为你的
userNotes是IEnumerable,写userNotes.Select(x => x.SymbolNotes) -
SymbolNotes 是 UserNotes 类的一部分,而不是 UserNotess 列表的一部分。您需要先从列表中选择一个 UserNotes 对象。你想要完成什么?你真的需要 UserNotes 列表吗?您想从所有 UserNotes 对象中获取单个 SymbolNotes 列表还是所有 SymbolNotes 列表?
-
我想添加这样的符号注释:userNotes.SymbolsNotes.Add(newSymbolNotes);
-
@Ortund 我想这样做:userNotes.SymbolsNotes.Add(newSymbolNotes);