【发布时间】:2014-02-19 11:20:04
【问题描述】:
我正在使用 WCF 服务访问控制器中的数据。
public ActionResult Index()
{
DataRerieveClient _proxy = new DataRerieveClient();
var orderDetails = _proxy.GetProductDetails(null);
return View();
}
现在如何将 orderdetails 从 Controller 传递到视图以及如何在视图中访问它们。
编辑:
我有一个模型:
public class OrderDetails
{
public int OrderId { get; set; }
public int ProductId { get; set; }
public decimal UnitPrice { get; set; }
public int quanity { get; set; }
public decimal Discount { get; set; }
}
而_proxy.GetProductDetails(null) 返回List<ServiceType.OrderDetails>
- 在这种情况下我是否需要本地模型?
- 如何在我的视图中的表格中显示列表值?
编辑2:
public class AutoMapperConfig
{
public static void Configure()
{
Mapper.Map(ServiceOrders.OrderDetails, NorthWindMVCWCF.Models.OrderDetails);
}
}
现在出现错误
“NorthWindMVCWCF.ServiceOrders.OrderDetails”是一个“类型”,在给定的上下文中无效 “NorthWindMVCWCF.Models.OrderDetails”是一个“类型”,在给定的上下文中无效
【问题讨论】:
-
我更新了我的答案。我想你可以从中得到一个好主意。
标签: c# asp.net asp.net-mvc wcf razor