/// <summary>Loads the data from the specified data reader on the specified Application event instance.</summary> internal static void FillData(IDataReader reader, Domain.ApplicationEvent entity) { var values = new object[reader.FieldCount]; reader.GetValues(values); if (values[1] != DBNull.Value) { entity.UserId = values[1] as string; } entity.Date = (DateTime)values[2]; entity.Event = values[3] as string; if (values[4] != DBNull.Value) { entity.ItemType = values[4] as string; } if (values[5] != DBNull.Value) { entity.ItemKey = values[5] as string; } if (values[6] != DBNull.Value) { entity.Data = values[6] as string; } if (values[7] != DBNull.Value) { entity.IP = values[7] as string; } }
/// <summary>Extracts the Application event instance from the current record of the specified data reader.</summary> public override IEntity Parse(IDataReader reader) { var result = new Domain.ApplicationEvent(); FillData(reader, result); EntityManager.SetSaved(result, reader.GetGuid(0)); return(result); }
/// <summary>Updates the specified existing Application event instance in the database.</summary> void Update(Domain.ApplicationEvent item) { if (ExecuteScalar(UPDATE_COMMAND, CommandType.Text, CreateParameters(item)).ToStringOrEmpty().IsEmpty()) { Cache.Current.Remove(item); throw new ConcurrencyException($"Failed to update the 'ApplicationEvents' table. There is no row with the ID of {item.ID}."); } }
/// <summary>Creates parameters for Inserting or Updating Application event records</summary> IDataParameter[] CreateParameters(Domain.ApplicationEvent item) { var result = new List <IDataParameter>(); result.Add(CreateParameter("OriginalId", item.OriginalId)); result.Add(CreateParameter("Id", item.GetId())); result.Add(CreateParameter("UserId", item.UserId)); result.Add(CreateParameter("Date", item.Date)); result.Add(CreateParameter("Event", item.Event)); result.Add(CreateParameter("ItemType", item.ItemType)); result.Add(CreateParameter("ItemKey", item.ItemKey)); result.Add(CreateParameter("Data", item.Data)); result.Add(CreateParameter("IP", item.IP)); return(result.ToArray()); }
/// <summary>Inserts the specified new Application event instance into the database.</summary> void Insert(Domain.ApplicationEvent item) { ExecuteScalar(INSERT_COMMAND, CommandType.Text, CreateParameters(item)); }