ViewModel 中的 PetaPoco 查询

发布于 2024-11-08 20:53:44 字数 320 浏览 2 评论 0原文

如果我有一个看起来像这样的视图模型,

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

温馨耳语 2024-11-15 20:53:44

我认为是的,如果列表值不改变,甚至可能缓存它。

I think so yes, maybe even cache it if the list values don't change.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文