【发布时间】:2019-07-03 18:18:27
【问题描述】:
我试图返回一个对象类,但是尝试失败了。
public class tbl_Product
{
public tbl_Product()
{
tbl_ProductDescription = new HashSet<tbl_ProductDescription>();
tbl_ProductPricing = new HashSet<tbl_ProductPricing>();
}
public Guid Id { get; set; }
public string ProductCode { get; set; }
public string ProductName { get; set; }
public Decimal Price { get; set; }
[InverseProperty("Product")]
public virtual ICollection<tbl_ProductPricing> tbl_ProductPricing { get; set; }
}
以下是我返回时的 WebAPI 函数:
[HttpGet]
public Task<ActionResult<ICollection<tbl_Product>>> GetProductList()
{
var result = _context.tbl_Product
.Include(a => a.tbl_ProductPricing).ToList();
return result;
}
但是,我收到了这个错误:
Cannot implicitly convert type 'System.Collections.Generic.List<Model.tbl_Product>' to 'System.Threading.Tasks.Task<Microsoft.AspNetCore.Mvc.ActionResult<System.Collections.Generic.ICollection<Model.tbl_Product>>>'
我可以知道我应该输入什么返回类型吗?
【问题讨论】:
标签: c# entity-framework linq asp.net-core