我正在使用 View 模型来将域模型与数据表示分开,但我不知道如何使用域模型中存在的数据库表关系。 例如这个域模型类应该如何在 View 模型中使用?在此示例中,CurrencyDictionary 是具有设置表外键的表。
public partial class Settings
{
public int Id { get; set; }
...List of properties...
public int ShopCurrency { get; set; }
public IEnumerable<SelectListItem> CurrencyList { get; set; }
public virtual CurrencyDictionary CurrencyDictionary { get; set; }
}
最佳答案
对于任何给定的相关域模型,您都有相应的 View 模型,因此您的 Settings
View 模型将包含相应的 CurrencyDictionary
View 模型,例如:
public class SettingsModel
{
public CurrencyDictionaryModel CurrencyDictionary { get; set; }
}
关于c# - 如何在 View 模型中使用域模型关系?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30838718/