ViewModel 中的 PetaPoco 查询
如果我有一个看起来像这样的视图模型,
public class AddressViewModel
{
public int AddressID {get;set;}
public string Street {get;set;}
public string Town {get;set;}
public SelectList Countries { get; set; }
}
我将如何填充它?
是否需要对数据库进行 2 次查询,其中 1 次用于填充地址信息,另一次将所有国家/地区返回到 SelectList 中?
If I had a viewmodel that looked something like this
public class AddressViewModel
{
public int AddressID {get;set;}
public string Street {get;set;}
public string Town {get;set;}
public SelectList Countries { get; set; }
}
How would I go about populating this?
Would it be 2 queries to the database, 1 to populate the address info and another to return all countries into the SelectList?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为是的,如果列表值不改变,甚至可能缓存它。
I think so yes, maybe even cache it if the list values don't change.