Example #1
0
        /// <summary>
        /// Method to list albums entities.
        /// </summary>
        /// <param name="op"></param>
        /// <returns>A list of albums entities.</returns>
        public IList <AlbumEntity> List(AlbumOptionsList op)
        {
            if (op == null)
            {
                ArgumentNullException e = new ArgumentNullException(nameof(op));
                log.Error(e.Output(), e);
                throw e;
            }

            // Initialize query.
            IQueryable <AlbumEntity> query = Connector.Albums;

            Query_Dependencies(ref query, op);

            // Filter by entity primary keys.
            query.QueryListInclude(op, "AlbumId");
            query.QueryListExclude(op, "AlbumId");


            // Check Section filters.
            query = Query_FilterSections(query, op);
            query = Query_FilterInfos(query, op);

            // Set number elements to skip.
            if (op.Start > 0)
            {
                query = query.Skip(op.Start);
            }

            // Set the number elements to select.
            if (op.Limit > 0)
            {
                query = query.Take(op.Limit);
            }

            return(query.ToList());
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="query"></param>
        /// <param name="op"></param>
        /// <returns></returns>
        private IQueryable <AlbumEntity> Query_FilterInfos(IQueryable <AlbumEntity> query, AlbumOptionsList op)
        {
            // Check for include Info primary keys to search in.
            if (op.IncludeInfoKeys != null && op.IncludeInfoKeys.Count > 0)
            {
                query = query.Where(x => x.InfosInAlbums.Any(y => op.IncludeInfoKeys.Contains(y.InfoId)));
            }

            // Check for exclude Info primary keys in search.
            if (op.ExcludeInfoKeys != null && op.ExcludeInfoKeys.Count > 0)
            {
                query = query.Where(x => x.InfosInAlbums.Any(y => !op.ExcludeInfoKeys.Contains(y.InfoId)));
            }

            return(query);
        }