I am trying to delete all table data where username = current user name. But there is some error on lambda expression and conversion."Cannot convert source type to target type. Any help?
public JsonResult DeleteChatMessages(int id) { string toId = Session["SessionUserName"].ToString(); tblChat tblchats = _obj.tblChat.Where(p => p.ToId == toId); _obj.tblChat.Remove(tblchats); _obj.SaveChanges(); return this.Json(true, JsonRequestBehavior.AllowGet); }
tblChat tblchats = _obj.tblChat.FirstOrDefault(p => p.ToId == toId)