using System.Linq.Expressions;
using Exam.Infrastructure.Extensions;
using Hotline.Exams.Sourcewares;
using Hotline.Share.Requests.Sourceware;
using SqlSugar;

namespace Hotline.Application.Exam.QueryExtensions.Sourcewares
{
    public static class SourcewareCategoryQueryExtesions
    {
        public static Expression<Func<ExamSourcewareCategory,bool>> GetExpression(this SourcewareCategoryRequest sourcewareCategoryPagedRequest)
        {
            Expression<Func<ExamSourcewareCategory, bool>> expression = m => m.Id != null;

            Expressionable<ExamSourcewareCategory> expressionable = new Expressionable<ExamSourcewareCategory>();

            expressionable.AndIF(sourcewareCategoryPagedRequest.Name.IsNotNullOrEmpty(), x => x.Name.Contains(sourcewareCategoryPagedRequest.Name));

            expression = expressionable.ToExpression();

            return expression;
        }

    }
}



