gpt4 book ai didi

Asp.net mvc3 : How to pull data from database and fill view model in one goal?

转载 作者:行者123 更新时间:2023-12-01 02:51:31 25 4
gpt4 key购买 nike

我需要从数据库中提取数据并填充 View 模型,有没有更好的方法来做到这一点?
目前我正在做这样的事情。

ViewModel vm = new ViewModel();
var recentBill = context.Money.Take(10);
foreach (var r in recnetBill)
{
vm.lst.Add(r);
}

最佳答案

IEnumerableToList()返回所述类型列表的函数。

vm.lst = context.Money.Take(10).ToList(); // returns a List<Money>

关于Asp.net mvc3 : How to pull data from database and fill view model in one goal?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4766308/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com