输入行时的断点无法输入并给出错误

时间:2019-01-04 20:22:17

标签: c# model-view-controller

当我将断点放在以下代码中时

产品。您可以跳到插入行并获得空异常消息。

public ActionResult Create([Bind(Include =“ ID,Name,CategoryId,Brand,Model,ImageUrl,Description,Price, 税收,折扣,库存, IsActive,CreateDate,CreateUserId,UpdateDate,UpdateUserId“)]产品, IEnumerable文件)

if (files != null&&files.Count()>0)
            {

                foreach (var item in files)
                {


                    Tuple<string, string> paths = ImageUpload.SaveImageWithThumbnail(item, 329, 380, 84, 84, false);

                    product.Images.Add(new Images

                    {
                        ImageUrl = paths.Item1,

                        ImageUrlt = paths.Item2,
                        RegisterDate = DateTime.Now,
                        CreateDate = DateTime.Now,
                        CreateUserId = 1,
                        UpdateDate = DateTime.Now,
                        UpdateUserId = 1

                    });
                }
            }

            **db.Products.Add(product);**
            db.SaveChanges();
            return RedirectToAction("Index");
        }

        ViewBag.CategoryId = new SelectList(db.Categories, "ID", "Name", product.CategoryId);
        return View(product);
    }

0 个答案:

没有答案