public void View(string datasetId) { ViewEntry item = this.context.ViewEntry.Where(t => t.DatasetId == datasetId).FirstOrDefault(); //if (this.context.ViewEntry.Where(t => t.DatasetId == datasetId).ToList().Count > 0) if(item != null) { item.Views++; this.context.UpdateObject(item); } else { item = new ViewEntry() {DatasetId = datasetId, Views=1 }; this.context.AddObject("ViewEntry", item); } this.context.SaveChanges(); }
public void View(string datasetId) { ViewEntry item = this.context.ViewEntry.Where(t => t.DatasetId == datasetId).FirstOrDefault(); //if (this.context.ViewEntry.Where(t => t.DatasetId == datasetId).ToList().Count > 0) if (item != null) { item.Views++; this.context.UpdateObject(item); } else { item = new ViewEntry() { DatasetId = datasetId, Views = 1 }; this.context.AddObject("ViewEntry", item); } this.context.SaveChanges(); }