Suppose I have two tables in my EF that are related:
public partial class Table1
{
public int Id {get; set;}
public int Table2Id {get; set;}
public virtual Table2 Table2 {get; set}
}
public partial class Table2
{
public Table2()
{
Table1 = new HashSet<Table1>
}
public int Id {get; set;}
public string datastring {get; set;}
public virtual Icollection<Table1> Table
}
I've simplified this obviously, but it resembles my real issue well enough.
Normally I can easily extract data from a form submit in jQuery if its just a single table. Which I would do like this:
form.serializeArray();
However, in this case I want to extract data from my form that goes into a 'child' table of my actual table.
<div class="container">
<form id="MyForm">
<input name="Table1.Table2.dataString" />
<button type="submit">save</button>
</form>
</div>
I have a feeling that this scenario is supported in .net MVC, but I have no idea how to actually do the naming in order to make it understand that it belongs to a 'child' table.
The quick and dirty way would be to target every input field in my form. But it's a large form, hence why I would really want to avoid that selector madness.
Update:
Even though I have not made my controller yet, I believe it should receive a Table1 object like so:
public ActionResult UpdateTables(Table1 table1)
{
//Logic to call serviceclass
}