如何通过 PredicateBuilder 为此构建动态 SQL?

How to build dynamic SQL by PredicateBuilder for this?

我正在使用此处 http://www.albahari.com/nutshell/predicatebuilder.aspx 所示的 PredicateBuilder,我想为 table 构建 LINQ,如何将此 transact-sql 转换为 LINQ?

SELECT * 
FROM Members 
WHERE Confirm=true 
AND CaseExist=true 
AND ( Username LIKE '%Jack%' OR Fullname LIKE '%Jack%' ) 
AND ( Tags IN ('3D','Photoshop','Java','Design') ) 
AND ( Catid+',' LIKE '%2,%' OR Catid+',' LIKE '%4,%' 
      OR Catid+',' LIKE '%5,%' OR Catid+',' LIKE '%21,%' ) 
ORDER BY Rate1 DESC, Rate2 DESC, Rate3 DESC, LatestLogin DESC, LatestUpdate DESC

我构建了这个:

var predicate = PredicateBuilder.True<Member>();

if (!string.IsNullOrEmpty(SearchString))
{
    predicate = predicate.And(x =>
        x.Username.Contains(SearchString)
        || x.FullName.Contains(SearchString)
    );
}

predicate = predicate.And(x => x.Confirmed == true)
                     .And(x => x.CaseExist == true);

但是我无法继续,所以有人可以建议我如何做吗?

    string[] arr = new string[] { "3D", "Photoshop", "Java", "Design" };
    predicate = predicate.And(x => arr.Contains(x.Tags));

    var arr2 = new[] { "2", "4", "5", "21" };
    var predicateCatid = PredicateBuilder.False<Member>();
    foreach (var cat in arr2)
    {
        predicateCatid = predicateCatid.Or(x => (x.Catid + ",").Contains(cat + ","));               
    }
    predicate = predicate.And(predicateCatid);

我想知道为什么Tags里面只能有一个标签