{"action":"opened","issue":{"url":"https://api.github.com/repos/thepirat000/Audit.NET/issues/111","repository_url":"https://api.github.com/repos/thepirat000/Audit.NET","labels_url":"https://api.github.com/repos/thepirat000/Audit.NET/issues/111/labels{/name}","comments_url":"https://api.github.com/repos/thepirat000/Audit.NET/issues/111/comments","events_url":"https://api.github.com/repos/thepirat000/Audit.NET/issues/111/events","html_url":"https://github.com/thepirat000/Audit.NET/issues/111","id":310432150,"number":111,"title":"Is OnScopeSaving supposed to add it to the current context before saving?","user":{"login":"rcheung9","id":34848405,"avatar_url":"https://avatars0.githubusercontent.com/u/34848405?v=4","gravatar_id":"","url":"https://api.github.com/users/rcheung9","html_url":"https://github.com/rcheung9","followers_url":"https://api.github.com/users/rcheung9/followers","following_url":"https://api.github.com/users/rcheung9/following{/other_user}","gists_url":"https://api.github.com/users/rcheung9/gists{/gist_id}","starred_url":"https://api.github.com/users/rcheung9/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rcheung9/subscriptions","organizations_url":"https://api.github.com/users/rcheung9/orgs","repos_url":"https://api.github.com/users/rcheung9/repos","events_url":"https://api.github.com/users/rcheung9/events{/privacy}","received_events_url":"https://api.github.com/users/rcheung9/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-04-02T08:50:10Z","updated_at":"2018-04-02T08:50:10Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"```\r\npublic override void OnScopeSaving(AuditScope auditScope)\r\n{\r\n\ttry\r\n\t{\r\n\t\tvar evt = auditScope.Event.GetEntityFrameworkEvent();\r\n\t\tvar entries = evt.Entries;\r\n\t\tvar transactionID = evt.TransactionId;\r\n\t\tvar errorMessage = evt.ErrorMessage;\r\n\r\n\t\tforeach (var entry in entries)\r\n\t\t{\r\n\t\t\tvar table = entry.Table;\r\n\t\t\tvar pk = entry.PrimaryKey[\"ID\"];\r\n\t\t\tvar changes = entry.Changes;\r\n\r\n\t\t\tforeach (var change in changes)\r\n\t\t\t{\r\n\t\t\t\tAuditLog.Add(new AuditLog\r\n\t\t\t\t{\r\n\t\t\t\t\tTable = table,\r\n\t\t\t\t\tPrimaryKey = (int)pk,\r\n\t\t\t\t\tColumnName = change.ColumnName,\r\n\t\t\t\t\tOriginalValue = change.OriginalValue.ToString(),\r\n\t\t\t\t\tNewValue = change.NewValue.ToString(),\r\n\t\t\t\t\tAuditAction = entry.Action,\r\n\t\t\t\t\tAuditDate = auditScope.Event.StartDate,\r\n\t\t\t\t\tTransactionId = transactionID,\r\n\t\t\t\t\tErrorMessage = errorMessage,\r\n\t\t\t\t\tMachineName = auditScope.Event.Environment.MachineName,\r\n\t\t\t\t\tUsername = auditScope.Event.Environment.UserName\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tcatch\r\n\t{\r\n\t\tDatabase.CurrentTransaction.Rollback();\r\n\t\tthrow;\r\n\t}\r\n}\r\n```\r\nThe AuditLog doesn't save if I don't call ```SaveChanges()```.  I thought it added it to the context before saving."}}
{"actor":{"display_login":"rcheung9"}}