c# - 无法将数据返回给邮递员
问题描述
我想从数据库中获取数据并将其返回给邮递员。在调试模式下,我可以看到有一些数据,但出于某种原因,我在邮递员中看不到它。
public async Task<ProductComparsionVM> GetProductComparsionByListId(int listId)
{
var comparsionList = _dbContext.ProductsComparsion.Include(z => z.ProductsToCompare).FirstOrDefault(z => z.Id == listId);
if (comparsionList == null)
return null;
var category = _dbContext.Categories.FirstOrDefault(z => z.Id == comparsionList.CategoryId);
var tmp = new ProductComparsionVM
{
ProductsToCompare2 = comparsionList.ProductsToCompare.ToList()
};
return tmp;
}
public class ProductComparsionVM
{
public int CategoryId { get; set; }
public string CategoryName { get; set; }
public int ListId { get; set; }
public int ProductId { get; set; }
public List<int> ProductsToCompare { get; set; }
public List<ProductToCompare> ProductsToCompare2 { get; set; }
}
还有其他字段,如果评论我可以在邮递员中获取ProductsToCompare2 = ..
编辑 1
[HttpPost]
public async Task<IActionResult> GetProductComparsionByListId([FromBody] ProductComparsionVM comparsion)
{
return Json(await _productRepo.GetProductComparsionByListId(comparsion.ListId));
}
解决方案
推荐阅读
- css - 嵌入的 Rumble 视频不会填满播放器
- python - 如何使用 python 归档多个文件夹?
- c - 为什么一个架构中包含多次标头,但在另一个架构中只包含一次?
- c++ - 错误:“使用指令指的是隐式定义的命名空间‘std’”
- python - python中用于解释的子进程效率
- android - 来自 navArgs 的数据(Bundle)在系统杀死和重新创建 Activity(和 Fragment)后是否仍然存在?
- java - jpackage not found - mac OS
- ios - 从 ARKit 中的 faceAnchor 中提取 yaw/pitch/roll
- php - 查询以使用另一个选择来选择某事
- python - Ansible 管道查找以使用解释器生成加密密码