【发布时间】:2021-12-01 20:42:13
【问题描述】:
我有这个来自数据库的实体
public class SettingsDb
{
public int Id { get; set; }
public string Section { get; set; }
public string Name { get; set; }
public string Value { get; set; }
}
意思是:
- Section:设置的主要部分(例如 FTP)
- 名称:属性的名称(例如,已启用、服务器等)
- 值:属性的值(例如,true、“www.server.it”等)
模型/分类它是
public class FtpSettings
{
public bool Enabled { get; set; }
public string Server { get; set; }
public int Port { get; set; }
public string Protocol { get; set; }
public string SSLStartMode { get; set; }
public string User { get; set; }
public string Password { get; set; }
}
我必须将列表 IList 扁平化为单个模型/dto 对象 FtpSettings(假设它已经从 SQL 查询部分过滤)
我怎样才能做到这一点?
谢谢。
【问题讨论】:
标签: c# asp.net .net automapper flatten