I have this entity from the database
public class SettingsDb
{
public int Id { get; set; }
public string Section { get; set; }
public string Name { get; set; }
public string Value { get; set; }
}
It means:
- Section: the main section of settings (e.g., FTP)
- Name: name of the property (e.g., Enabled, Server etc.)
- Value: value of the property (e.g. true, "www.server.it" etc)
The model/to class it is
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; }
}
I have to flat the list IList to a single model/dto object FtpSettings (supposing it is already filtered from the section from SQL query)
How can I achieve this?
Thank you.
2
Answers
after troubling I did the following.
A converter
It can be used as
It must be installed AutoMapper and UniversalTypeConverter by Nuget
Or you can just add your Ilist directly in your View like this: