我最近开始使用自定义的ViewModels(例如,CustomerViewModel)保持LINQ的使用的ViewModels(ASP.NET MVC)时,SQL活着
public class CustomerViewModel
{
public IList<Customer> Customers{ get; set; }
public int ProductId{ get; set; }
public CustomerViewModel(IList<Customer> customers, int productId)
{
this.Customers= customers;
this.ProductId= productId;
}
public CustomerViewModel()
{
}
}
...,我现在将它们传递给我的看法,而不是这些集合本身(例如,var Custs = repository.getAllCusts(id)),因为它似乎是很好的做法。
我遇到的问题是,当使用ViewModels;当它达到这个观点时,我已经失去了对客户进行懒惰加载的能力。在使用它们之前我不相信这是事实。
在仍使用ViewModels的情况下是否可以保留延迟加载的能力? 或者我必须急于使用这种方法加载?
感谢, 钢钣。