schangxiang@126.com
2025-05-07 cace264ad9d86a7831099810b079da1141957add
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System.Linq.Expressions;
 
namespace CMS.Plugin.PipeLineLems.Domain.MyTestEntityNames
{
    /// <summary>
    /// MyTestEntityName规约
    /// </summary>
    public class MyTestEntityNameSpecification : Volo.Abp.Specifications.Specification<MyTestEntityName>
    {
        private readonly string _name;
 
        /// <summary>
        /// Initializes a new instance of the <see cref="MyTestEntityNameSpecification"/> class.
        /// </summary>
        public MyTestEntityNameSpecification()
        {
        }
 
        /// <summary>
        /// Initializes a new instance of the <see cref="MyTestEntityNameSpecification"/> class.
        /// </summary>
        /// <param name="name">The name.</param>
        public MyTestEntityNameSpecification(string name = null)
        {
            _name = name;
        }
 
        /// <inheritdoc />
        public override Expression<Func<MyTestEntityName, bool>> ToExpression()
        {
            Expression<Func<MyTestEntityName, bool>> expression = c => 1 == 1;
 
            if (_name != null)
            {
                expression = expression.And(c => c.Name == _name);
            }
 
            return expression;
        }
    }
}