Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. public async Task<ActionResult> Messages()
  2. {
  3. var collection = db.Messages;
  4. ViewBag.NotifierEntity = db.GetNotifierEntity<Message>(collection).ToJson();
  5.  
  6. return View(await collection.ToListAsync());
  7. }
  8.  
  9. public async Task<ActionResult> Messages()
  10. {
  11. var username = CurrentUser().UserName;
  12. var collection = db.Messages.Where(m => m.Recipients
  13. .All(u => u.UserName == username));
  14. ViewBag.NotifierEntity = db.GetNotifierEntity<Message>(collection).ToJson();
  15. return View(await collection.ToListAsync());
  16. }
  17.  
  18. public static NotifierEntity FromJson(string value)
  19. {
  20. if (String.IsNullOrEmpty(value))
  21. throw new ArgumentNullException("NotifierEntity Value can not be null.");
  22.  
  23. //return new JavaScriptSerializer().Deserialize<NotifierEntity>(value);
  24. return JsonConvert.DeserializeObject<NotifierEntity>(value, new JsonSerializerSettings {
  25. NullValueHandling = NullValueHandling.Ignore
  26. });
  27. }
  28.  
  29. [Newtonsoft.Json.JsonSerializationException] {"Error converting value "p__linq__0" to type 'System.Data.SqlClient.SqlParameter'. Path 'SqlParameters[0]', line 1, position 1010."}
  30.  
  31. [InnerException] {"Could not cast or convert from System.String to System.Data.SqlClient.SqlParameter."}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement