/// <summary>
 /// Deprecated Method for adding a new object to the SearchEvents EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToSearchEvents(SearchEvent searchEvent)
 {
     base.AddObject("SearchEvents", searchEvent);
 }
 // **************************************
 //LogUserActionEvent
 // **************************************
 private static void LogEvent(SearchEvent logEvent)
 {
     using (var ctx = new SongSearchContext()) {
         ctx.ContextOptions.LazyLoadingEnabled = false;
         try {
             ctx.SearchEvents.AddObject(logEvent);
             ctx.SaveChanges();
         }
         catch (Exception ex) { Log.Error(ex); }
     }
 }
 /// <summary>
 /// Create a new SearchEvent object.
 /// </summary>
 /// <param name="searchEventId">Initial value of the SearchEventId property.</param>
 /// <param name="searchEventDate">Initial value of the SearchEventDate property.</param>
 /// <param name="sessionId">Initial value of the SessionId property.</param>
 /// <param name="userId">Initial value of the UserId property.</param>
 /// <param name="resultCount">Initial value of the ResultCount property.</param>
 /// <param name="queryString">Initial value of the QueryString property.</param>
 /// <param name="searchActionId">Initial value of the SearchActionId property.</param>
 public static SearchEvent CreateSearchEvent(global::System.Int64 searchEventId, global::System.DateTime searchEventDate, global::System.String sessionId, global::System.Int32 userId, global::System.Int32 resultCount, global::System.String queryString, global::System.Int32 searchActionId)
 {
     SearchEvent searchEvent = new SearchEvent();
     searchEvent.SearchEventId = searchEventId;
     searchEvent.SearchEventDate = searchEventDate;
     searchEvent.SessionId = sessionId;
     searchEvent.UserId = userId;
     searchEvent.ResultCount = resultCount;
     searchEvent.QueryString = queryString;
     searchEvent.SearchActionId = searchActionId;
     return searchEvent;
 }
        // **************************************
        // LogUserEvent: ContentActionEvent
        // **************************************
        public static void LogSearchEvent(SearchActions action, string searchTerms, int resultsCount)
        {
            var actionEvent = new SearchEvent() {
                SearchActionId = (int)action,
                UserId = Account.User().UserId,
                SearchEventDate = DateTime.Now,
                SessionId = CurrentSessionId(),
                QueryString = searchTerms,
                ResultCount = resultsCount
            };

            LogActionEventDelegate<SearchEvent> logActionEventDelegate = new LogActionEventDelegate<SearchEvent>(LogEvent);

            logActionEventDelegate.BeginInvoke(actionEvent, null, null);
        }