I have the following code:
var game = (from k in db.GamerTBLs
where k.UserName == User.Identity.Name
select k.GamerID).Single();
return View(game);
and this is my controller:
[HttpPost]
public ActionResult Create(GameTBL gametbl)
{
if (ModelState.IsValid)
{
db.GameTBLs.Add(gametbl);
db.SaveChanges();
return RedirectToAction("Index");
}
var game = (from k in db.GamerTBLs where k.UserName == User.Identity.Name
select k.GamerID).Single();
return View(game);
}
I am trying to populate the Gamer ID to the related table Game which has the the foreign key GamerIDFK.
Can any one please shed some light, if you require more information please let me know