代码之家  ›  专栏  ›  技术社区  ›  SeeSharpNewbie121

.Net MVC web应用程序-如何动态存储多个输入(在一个属性内)-DatabaseFirst

  •  0
  • SeeSharpNewbie121  · 技术社区  · 3 年前

    我可能没有用最好的方式表达我的问题,但问题就在这里。我的视图中有一张表: https://ibb.co/0fXwfPn

    以下是.cshtml中所述表的代码: https://ibb.co/qgRjQM6

    <table class="table table-bordered table-responsive table-hover row col-md-12 tablelightgrey">
        <tr>
            <th>Name</th>
            <th>Role</th>
            <th>Telephone</th>
            <th>Email</th>
        </tr>
        <tr>
            <td> @Html.EditorFor(model => model.MeetingAttendee.MeetingAttendeeName, new { htmlAttributes = new { @class = "form-control detailsTextBox" } })</td>
            <td>@Html.EditorFor(model => model.MeetingAttendee.MeetingAttendeeRole, new { htmlAttributes = new { @class = "form-control detailsTextBox" } })</td>
            <td>@Html.EditorFor(model => model.MeetingAttendee.MeetingAttendeeTelephone, new { htmlAttributes = new { @class = "form-control detailsTextBox" } })</td>
            <td>@Html.EditorFor(model => model.MeetingAttendee.MeetingAttendeeEmail, new { htmlAttributes = new { @class = "form-control detailsTextBox" } })</td>
        </tr>
        <tr>
            <td> @Html.EditorFor(model => model.MeetingAttendee.MeetingAttendeeName, new { htmlAttributes = new { @class = "form-control detailsTextBox" } })</td>
            <td>@Html.EditorFor(model => model.MeetingAttendee.MeetingAttendeeRole, new { htmlAttributes = new { @class = "form-control detailsTextBox" } })</td>
            <td>@Html.EditorFor(model => model.MeetingAttendee.MeetingAttendeeTelephone, new { htmlAttributes = new { @class = "form-control detailsTextBox" } })</td>
            <td>@Html.EditorFor(model => model.MeetingAttendee.MeetingAttendeeEmail, new { htmlAttributes = new { @class = "form-control detailsTextBox" } })</td>
        </tr>
        <tr>
            <td> @Html.EditorFor(model => model.MeetingAttendee.MeetingAttendeeName, new { htmlAttributes = new { @class = "form-control detailsTextBox" } })</td>
            <td>@Html.EditorFor(model => model.MeetingAttendee.MeetingAttendeeRole, new { htmlAttributes = new { @class = "form-control detailsTextBox" } })</td>
            <td>@Html.EditorFor(model => model.MeetingAttendee.MeetingAttendeeTelephone, new { htmlAttributes = new { @class = "form-control detailsTextBox" } })</td>
            <td>@Html.EditorFor(model => model.MeetingAttendee.MeetingAttendeeEmail, new { htmlAttributes = new { @class = "form-control detailsTextBox" } })</td>
        </tr>
    </table>
    

    如果表中的所有行都已填充,则只有第一行内容存储在“名称”、“角色”、“电话”、“电子邮件”属性中。我明白了,因为所有的属性都是一样的。

    我在想可能是一个字符串数组,但问题是,这个应用程序是建立在传统的数据库优先模型(edmx文件,然后生成模型)的基础上的。

    因此,我在SQL Server中手动创建了表,然后自动生成的类如下: https://ibb.co/T19xrDQ

    现在我无法更改这个类中的任何内容,因为它是一个自动生成的类。我在想一串数组。

    只是想知道我该怎么解决这个问题?该表的每一行都需要保存在我的数据库表的一行中- https://ibb.co/N3Ww5mm 因此,我无法将所有要保存到db列的值字符串化。

    TIA

    0 回复  |  直到 3 年前