Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/268.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# IList数据集插入到数据库表_C#_Asp.net Mvc_Entity Framework_Linq_List - Fatal编程技术网

C# IList数据集插入到数据库表

C# IList数据集插入到数据库表,c#,asp.net-mvc,entity-framework,linq,list,C#,Asp.net Mvc,Entity Framework,Linq,List,我将数据集设置为PostAction方法的模型对象,如下所示 一旦我展开上面的对象,它就具有以下属性 一旦我在上面展开ListProductFieldsIList,它就具有以下属性 一旦我在上面展开ListProductFieldsIList的对象值,[0]th值,它就有以下属性及其值 这是相关的模型类文件 public class AddNewProduct { public string Product_ID { get; set; } public string P

我将数据集设置为PostAction方法的模型对象,如下所示

一旦我展开上面的对象,它就具有以下属性

一旦我在上面展开ListProductFieldsIList,它就具有以下属性

一旦我在上面展开ListProductFieldsIList的对象值,
[0]th
值,它就有以下属性及其值

这是相关的模型类文件

public class AddNewProduct
{
    public string Product_ID { get; set; }
    public string ProductTypeID { get; set; }
    public string ProductCategoryID { get; set; }
    public string Subsidary_ID { get; set; }
    public string Field_ID { get; set; }
    public string ProductFieldNameEn { get; set; }
    public string ProductFieldNameAr { get; set; }
    public string ApprovalStatus { get; set; }
    public string Status { get; set; }
    public IList<AB_ProductTypeCategoryField> ListProductFields { get; set; }
}

public partial class AB_ProductTypeCategoryField
{
    public string ProductFieldID { get; set; }
    public string ProductFieldNameEn { get; set; }
    public string ProductFieldNameAr { get; set; }
    public string ProdcutFieldDiscriptionEn { get; set; }
    public string ProductFieldDiscriptionAr { get; set; }
    public string Status { get; set; }
    public bool IsChecked { get; set; }
    public string CreatedBy { get; set; }
    public Nullable<System.DateTime> CreatedDate { get; set; }
    public string UpdatedBy { get; set; }
    public Nullable<System.DateTime> UpdatedDate { get; set; }

    public string Field_Value_EN { get; set; }
    public string Field_Value_AR { get; set; }
}

public partial class AB_Product_vs_Field
{
    public string Product_ID { get; set; }
    public string Field_ID { get; set; }
    public string Field_Value_EN { get; set; }
}
但我有以下错误

一个或多个实体的验证失败。有关详细信息,请参阅“EntityValidationErrors”属性

我将调试点放在这行的前面
db.AB\u Product\u vs\u Field.Add(insertproductvalue)我的代码。一旦这一行调用其指向
App\u Browsers.9u0xu-\u o.0.cs
文件中的以下部分

public class ApplicationBrowserCapabilitiesFactory : System.Web.Configuration.BrowserCapabilitiesFactory {

    public override void ConfigureCustomCapabilities(System.Collections.Specialized.NameValueCollection headers, System.Web.HttpBrowserCapabilities browserCaps) {
    }
这是我收到的错误页面,一旦这一行被调用

这些是错误的图像

图1:

图2:


我在for循环中添加了以下行,这样它就可以保存每个元组的记录

@Html.HiddenFor(m => m.ListProductFields[i].ProductFieldID)
然后我的查看页面显示如下

<div class="col-md-10">
    @Html.HiddenFor(m => m.ListProductFields[i].ProductFieldID)
    @Html.TextAreaFor(m => m.ListProductFields[i].Field_Value_EN,
        new { @class = "form-control summernote", @row = 5 })
</div>

@Html.HiddenFor(m=>m.ListProductFields[i].ProductFieldID)
@Html.TextAreaFor(m=>m.ListProductFields[i].Field\u Value\u EN,
新的{@class=“formcontrol summernote”,@row=5})

查看“EntityValidationErrors”属性了解更多详细信息-我们看不到:)@StephenMuecke问题已更新,在这里我可以看到
EntityValidationErrors
,?@HenkHolterman实际上我无法通知
EntityValidationErrors
,我应该看哪里?@StephenMuecke我添加了更多图片,但是我不明白有什么问题here@HenkHolterman我需要为这个添加try catch吗?
<div class="col-md-10">
    @Html.HiddenFor(m => m.ListProductFields[i].ProductFieldID)
    @Html.TextAreaFor(m => m.ListProductFields[i].Field_Value_EN,
        new { @class = "form-control summernote", @row = 5 })
</div>