I am trying to track if it is possible, in Entity Framework, to check if database table has new records added. I am trying to get records from controller only if there is any new record added to database table. any suggestion?
Server:
[HttpGet]
public JsonResult DisplayChatMsgs()
{
var chatMsgs = dbObj.tblChats.ToList();
return Json(chatMsgs, JsonRequestBehavior.AllowGet);
}
Client:
$.ajax({
url: "Default/DisplayChatMsgs",
type: "Get",
success: function (data) {
//var mdata = $.parseJSON(data.d);
//The Div to be populated
$('#msgBox').empty();
content = "";
//Looping thru each record
$.each(data, function (i, record) {
//Properties available in Model
//We need to specify the properties in our model
content += "<tr><td><b>" + record.toName + "</b>:</td><td>" + record.chatMsg + "</td></tr>";
});
table = "<table>" + content + "</table>"
$(table).appendTo('#msgBox');
$("#msgBox").animate({ scrollTop: $('#msgBox')[0].scrollHeight }, 1000);
}
});