DocSas/PropertyService.Domain/DataBaseContext/PSRepository.cs
/// <summary>
/// get as an asynchronous operation.
/// </summary>
/// <param name="filter">The filter.</param>
/// <param name="navigationPath">The navigation path.</param>
/// <param name="numberOfRecords">The number of records.</param>
/// <param name="isOrderDesc">if set to <c>true</c> [is order desc].</param>
/// <returns>Task&lt;IEnumerable&lt;T&gt;&gt;.</returns>
get as an asynchronous operation.
get as an asynchronous operation .
public async Task<IEnumerable<T>> GetAsync(Expression<Func<T, bool>> filter = null, string navigationPath = null, int numberOfRecords = 1000, bool isOrderDesc = false)
        {
            try
            {
                if (isOrderDesc)
                {
                    if (string.IsNullOrWhiteSpace(navigationPath))
                    {
                        if (filter == null)
                        {
                            return await _entities.OrderByDescending(x => x.AddedDateUtc).Take(numberOfRecords).ToListAsync();
                        }
                        return await _entities.Where(filter).OrderByDescending(x => x.AddedDateUtc).Take(numberOfRecords).ToListAsync();
                    }
                    if (filter == null)
                    {
                        return await _entities.OrderByDescending(x => x.AddedDateUtc).Take(numberOfRecords).Include(navigationPath).ToListAsync();
                    }
                    return await _entities.Where(filter).OrderByDescending(x => x.AddedDateUtc).Take(numberOfRecords).Include(navigationPath).ToListAsync();
                }
                if (string.IsNullOrWhiteSpace(navigationPath))
                {
                    if (filter == null)
                    {
                        return await _entities.Take(numberOfRecords).ToListAsync();
                    }
                    return await _entities.Where(filter).Take(numberOfRecords).ToListAsync();
                }
                if (filter == null)
                {
                    return await _entities.Take(numberOfRecords).Include(navigationPath).ToListAsync();
                }
                return await _entities.Where(filter).Take(numberOfRecords).Include(navigationPath).ToListAsync();
            }
            catch (Exception ex)
            {
                throw new DSCClientException(ExceptionMsg.ErrorOccuredTryAgain, ex);
            }
        }
public async Task < IEnumerable < T > > GetAsync ( Expression < Func < T , bool > > filter = null , string navigationPath = null , int numberOfRecords = 1000 , bool isOrderDesc = false ) { try { if ( isOrderDesc ) { if ( string . IsNullOrWhiteSpace ( navigationPath ) ) { if ( filter == null ) { return await _entities . OrderByDescending ( x => x . AddedDateUtc ) . Take ( numberOfRecords ) . ToListAsync ( ) ; } return await _entities . Where ( filter ) . OrderByDescending ( x => x . AddedDateUtc ) . Take ( numberOfRecords ) . ToListAsync ( ) ; } if ( filter == null ) { return await _entities . OrderByDescending ( x => x . AddedDateUtc ) . Take ( numberOfRecords ) . Include ( navigationPath ) . ToListAsync ( ) ; } return await _entities . Where ( filter ) . OrderByDescending ( x => x . AddedDateUtc ) . Take ( numberOfRecords ) . Include ( navigationPath ) . ToListAsync ( ) ; } if ( string . IsNullOrWhiteSpace ( navigationPath ) ) { if ( filter == null ) { return await _entities . Take ( numberOfRecords ) . ToListAsync ( ) ; } return await _entities . Where ( filter ) . Take ( numberOfRecords ) . ToListAsync ( ) ; } if ( filter == null ) { return await _entities . Take ( numberOfRecords ) . Include ( navigationPath ) . ToListAsync ( ) ; } return await _entities . Where ( filter ) . Take ( numberOfRecords ) . Include ( navigationPath ) . ToListAsync ( ) ; } catch ( Exception ex ) { throw new DSCClientException ( ExceptionMsg . ErrorOccuredTryAgain , ex ) ; } }
get as an asynchronous operation.
get as an asynchronous operation .
None
filter
Expression<Func<T, bool>>
None
navigationPath
string
The navigation path.
The navigation path .
numberOfRecords
int
The number of records.
The number of records .
isOrderDesc
bool
if set to true
if set to true