/// <summary> /// Gets a collection of all <see cref="INotificationMethod"/>. /// </summary> /// <param name="keys"> /// The keys. /// </param> /// <returns> /// The <see cref="IEnumerable{INotificationMethod}"/>. /// </returns> protected override IEnumerable <INotificationMethod> PerformGetAll(params Guid[] keys) { var dtos = new List <NotificationMethodDto>(); if (keys.Any()) { // This is to get around the WhereIn max limit of 2100 parameters and to help with performance of each WhereIn query var keyLists = keys.Split(400).ToList(); // Loop the split keys and get them foreach (var keyList in keyLists) { dtos.AddRange(Database.Fetch <NotificationMethodDto>(GetBaseQuery(false).WhereIn <NotificationMethodDto>(x => x.Key, keyList, SqlSyntax))); } } else { dtos = Database.Fetch <NotificationMethodDto>(GetBaseQuery(false)); } var factory = new NotificationMethodFactory(); foreach (var dto in dtos) { yield return(factory.BuildEntity(dto)); } }
/// <summary> /// Updates an existing item in the database. /// </summary> /// <param name="entity"> /// The entity. /// </param> protected override void PersistUpdatedItem(INotificationMethod entity) { ((Entity)entity).UpdatingEntity(); var factory = new NotificationMethodFactory(); var dto = factory.BuildDto(entity); Database.Update(dto); entity.ResetDirtyProperties(); }
/// <summary> /// Adds a new item to the database. /// </summary> /// <param name="entity"> /// The entity. /// </param> protected override void PersistNewItem(INotificationMethod entity) { ((Entity)entity).AddingEntity(); var factory = new NotificationMethodFactory(); var dto = factory.BuildDto(entity); Database.Insert(dto); entity.Key = dto.Key; entity.ResetDirtyProperties(); }
/// <summary> /// Gets a <see cref="INotificationMethod"/> by query. /// </summary> /// <param name="key"> /// The key. /// </param> /// <returns> /// The <see cref="INotificationMethod"/>. /// </returns> protected override INotificationMethod PerformGet(Guid key) { var sql = GetBaseQuery(false) .Where(GetBaseWhereClause(), new { Key = key }); var dto = Database.Fetch <NotificationMethodDto>(sql).FirstOrDefault(); if (dto == null) { return(null); } var factory = new NotificationMethodFactory(); return(factory.BuildEntity(dto)); }
/// <summary> /// Gets a collection of all <see cref="INotificationMethod"/>. /// </summary> /// <param name="keys"> /// The keys. /// </param> /// <returns> /// The <see cref="IEnumerable{INotificationMethod}"/>. /// </returns> protected override IEnumerable <INotificationMethod> PerformGetAll(params Guid[] keys) { if (keys.Any()) { foreach (var key in keys) { yield return(Get(key)); } } else { var factory = new NotificationMethodFactory(); var dtos = Database.Fetch <NotificationMethodDto>(GetBaseQuery(false)); foreach (var dto in dtos) { yield return(factory.BuildEntity(dto)); } } }