public void Post([FromBody] dynamic value) { string emailAddress = value.emailAddress; int game = value.game; using (var server = LightSwitchApplication.ServerApplicationContext.CreateContext()) { var existingVote = (from g in server.DataWorkspace.ApplicationData.VotesSet.GetQuery().Execute() where g.EmailAddress.Equals(emailAddress, StringComparison.InvariantCultureIgnoreCase) select g).SingleOrDefault(); if (existingVote != null) { existingVote.Game_Id = game; } else { var vote = server.DataWorkspace.ApplicationData.VotesSet.AddNew(); vote.EmailAddress = emailAddress; vote.Game_Id = game; } server.DataWorkspace.ApplicationData.SaveChanges(); } }