我可以在下面的代码中填写两个表格吗?Address , Cod , Cost 应填写 tbl_Reciver。但是 Lname 、 Name 、 Tell 应该填写 Tbl_Sender。我可以在这里填两张桌子吗?
public static bool InsertInTables(string Address, string Cod, int? cost,string Lname, string Name, string Tell )
{
MyContext db = new MyContext();
try
{
//Can i fill Tbl_Sender like tbl_Reciver here
var tbl1 = new tbl_Reciver
{
id = MaxIdInTbl (),
Address_s = Address,
Cod_s = Cod,
Cost_s = cost,
//i wanna fill below fields in tbl_Sender
// Lname_s = Lname,
// Name_s = Name,
//Tell_s = Tell,
};
//is it possible i fill two tables ?
db.tbl_Reciver.Add(tbl1);
db.SaveChanges();
return true;
}
catch
{
return false;
}
}