/// <summary>
        /// Gets the collection of all <see cref="IAuditLog"/>
        /// </summary>
        /// <param name="keys">
        /// The keys.
        /// </param>
        /// <returns>
        /// The <see cref="IEnumerable{IAuditLog}"/>.
        /// </returns>
        protected override IEnumerable <IAuditLog> PerformGetAll(params Guid[] keys)
        {
            var dtos = new List <AuditLogDto>();

            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 <AuditLogDto>(GetBaseQuery(false).WhereIn <AuditLogDto>(x => x.Key, keyList, SqlSyntax)));
                }
            }
            else
            {
                dtos = Database.Fetch <AuditLogDto>(GetBaseQuery(false));
            }

            var factory = new AuditLogFactory();

            foreach (var dto in dtos)
            {
                yield return(factory.BuildEntity(dto));
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Gets a <see cref="IAuditLog"/>
        /// </summary>
        /// <param name="key">
        /// The key.
        /// </param>
        /// <returns>
        /// The <see cref="IAuditLog"/>.
        /// </returns>
        protected override IAuditLog PerformGet(Guid key)
        {
            var sql = GetBaseQuery(false)
                      .Where(GetBaseWhereClause(), new { Key = key });


            var dto = Database.Fetch <AuditLogDto>(sql).FirstOrDefault();

            if (dto == null)
            {
                return(null);
            }

            var factory = new AuditLogFactory();

            var customer = factory.BuildEntity(dto);

            return(customer);
        }
Esempio n. 3
0
 /// <summary>
 /// Gets the collection of all <see cref="IAuditLog"/>
 /// </summary>
 /// <param name="keys">
 /// The keys.
 /// </param>
 /// <returns>
 /// The <see cref="IEnumerable{IAuditLog}"/>.
 /// </returns>
 protected override IEnumerable <IAuditLog> PerformGetAll(params Guid[] keys)
 {
     if (keys.Any())
     {
         foreach (var id in keys)
         {
             yield return(Get(id));
         }
     }
     else
     {
         var factory = new AuditLogFactory();
         var dtos    = Database.Fetch <AuditLogDto>(GetBaseQuery(false));
         foreach (var dto in dtos)
         {
             yield return(factory.BuildEntity(dto));
         }
     }
 }