internal static SqlDataRecord ToSqlDataRecord(this EventEntry record, string instanceName) { var sqlDataRecord = new SqlDataRecord(SqlMetaData); sqlDataRecord.SetValue(0, instanceName ?? string.Empty); sqlDataRecord.SetValue(1, record.ProviderId); sqlDataRecord.SetValue(2, record.Schema.ProviderName ?? string.Empty); sqlDataRecord.SetValue(3, record.EventId); sqlDataRecord.SetValue(4, (long)record.Schema.Keywords); sqlDataRecord.SetValue(5, (int)record.Schema.Level); sqlDataRecord.SetValue(6, (int)record.Schema.Opcode); sqlDataRecord.SetValue(7, (int)record.Schema.Task); sqlDataRecord.SetValue(8, record.Timestamp); sqlDataRecord.SetValue(9, record.Schema.Version); sqlDataRecord.SetValue(10, (object)record.FormattedMessage ?? DBNull.Value); sqlDataRecord.SetValue(11, (object)EventEntryUtil.XmlSerializePayload(record) ?? DBNull.Value); // sqlDataRecord.SetValue(12, record.ActivityId); // sqlDataRecord.SetValue(13, record.RelatedActivityId); // sqlDataRecord.SetValue(14, record.ProcessId); // sqlDataRecord.SetValue(15, record.ThreadId); sqlDataRecord.SetValue(12, EventEntryUtil.GetPayloadValue(record, "IpAddress")); sqlDataRecord.SetValue(13, EventEntryUtil.GetPayloadValue(record, "Source")); sqlDataRecord.SetValue(14, EventEntryUtil.GetPayloadValue(record, "UserName")); sqlDataRecord.SetValue(15, EventEntryUtil.GetPayloadValue(record, "SessionId")); sqlDataRecord.SetValue(16, I18NHelper.DateTimeOffsetParseInvariant(EventEntryUtil.GetPayloadValue(record, "OccurredAt"))); var actionName = EventEntryUtil.GetPayloadValue(record, "ActionName"); sqlDataRecord.SetValue(17, actionName); // if (!string.IsNullOrWhiteSpace(actionName)) // { Guid correlationId; if (Guid.TryParse(EventEntryUtil.GetPayloadValue(record, "CorrelationId"), out correlationId)) { sqlDataRecord.SetValue(18, correlationId); } double duration = 0; if (double.TryParse(EventEntryUtil.GetPayloadValue(record, "Duration"), out duration)) { sqlDataRecord.SetValue(19, duration); } // } return(sqlDataRecord); }