private void Submit_Click(object sender, EventArgs e)
{
ScoutContext db = new ScoutContext();
ScoutData cust = new ScoutData();
cust.FName = textBox1.Text;
cust.LName = textBox2.Text;
cust.FName = textBox3.Text;
cust.FaWork = textBox4.Text;
cust.MoName = textBox5.Text;
cust.MaWork = textBox6.Text;
cust.PlaceOfBirth = textBox7.Text;
cust.City = textBox8.Text;
cust.School = textBox9.Text;
cust.FaceBook = textBox10.Text;
cust.Phone = textBox11.Text;
cust.MPhone = textBox12.Text;
cust.IDNumber = textBox13.Text;
cust.NOfQaid = textBox14.Text;
cust.GroupID = ?????????????????
db.SaveChanges();
}
i work on Windows form, i have this data that the user fill the textbox, after that i need to save the data to my context ( database ), this is my code to insert data to my data base , but i have data ( numbers and some string ) the user will chose from ComboBox. i need to get this data and save it to a list of object , this is the code :
public class Groups
{
[Key]
public string GroupsID { set; get; }
public string NameOfGroup { set; get; }
***public virtual List<ScoutData> Members { set; get; }***
}
The context:
public class ScoutContext : DbContext
{
public ScoutContext()
: base("Scout")
{
// if (!Database.Exists("ScoutData"))
// Database.SetInitializer(new DropCreateDatabaseAlways<ScoutContext>());
}
public DbSet<ScoutData> ScoutDatas { set; get; }
public DbSet<Groups> GroupesScout { set; get; }
}
i need to get this data from the combobox to Members list and save it to a list of object (Members)