我读过这篇文章并对此感到疑惑。
我的应用程序包含 4 层
到目前为止,我已经将 VM 放在 UI 层中,并且它是不同类的组合。像这样的东西
public class CompanyVMIndex
{
public CompanyVM Company { get; set; }
public BillingAddressVM BillingAddress { get; set; }
public List<ShippingAddressVM> ShippingAddress { get; set; }
public List<CompanyContactVM> CompanyContact { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我现在很困惑如何将这些数据从 UI 发送到 BLL,然后是 DAL。我已经阅读了 automapper,但它是否处理这种情况,如果是,那么如何处理?到目前为止,我已经决定将虚拟机移动到实体层,实体层将连接到所有三层,以便我可以在同一层发送和接收数据,还有其他好主意吗?
这就是我将数据从 UI 传递到 BLL 的方式
public ActionResult Create(CompanyVMIndex companyVM)
{
if (ModelState.IsValid)
{
//Calling BLL here
BLLFunction(companyVM)
}
return View("Index");
}
Run Code Online (Sandbox Code Playgroud)
然后在 BLL 和 DAL 中类似的东西与 …
c# asp.net-mvc entity-framework viewmodel n-tier-architecture