Exemple #1
0
        public static WorkItemLinkInfo [] QueryLinks(
            this TfsTeamProjectCollection tpc,
            Expression <Predicate <WorkItem> > sourcePredicate,
            Expression <Predicate <WorkItem> > targetPredicate,
            string linkType,
            QueryLinkMode mode
            )
        {
            var qb = new QueryBuilder(QueryType.Link);


            var sourceLambda = sourcePredicate as LambdaExpression;
            var targetLambda = targetPredicate as LambdaExpression;


            var whereSourceTranslator = new WhereClauseTranslator(new WorkItemHelper(), "Source");

            var sourceFilter = whereSourceTranslator.Translate(sourceLambda.Body, qb, sourceLambda.Parameters[0].Name);

            if (!string.IsNullOrEmpty(sourceFilter))
            {
                qb.AddWhereClause(sourceFilter);
            }


            var whereTargetTranslator = new WhereClauseTranslator(new WorkItemHelper(), "Target");

            var targetFilter = whereTargetTranslator.Translate(sourceLambda.Body, qb, targetLambda.Parameters[0].Name);

            if (!string.IsNullOrEmpty(targetFilter))
            {
                qb.AddWhereClause(targetFilter);
            }

            qb.AddQueryLinkMode(mode);


            var q = qb.BuildQuery(tpc, null, null);

            return(q.GetLinks());
        }
Exemple #2
0
        /// <summary>
        /// Processes the where clause.
        /// </summary>
        /// <param name="lambda">The lambda.</param>
        private void ProcessWhereClause(LambdaExpression lambda)
        {
            if (lambda.Parameters.Count == 0)
            {
                throw new InvalidOperationException("invalid where clase");

            }
            if ((lambda.Parameters.Count != 1) ||
               (!IsAWorkItem(lambda.Parameters[0].Type)))
            {
                throw new InvalidOperationException("invalid where clase");
            }

            var whereTranslator = new WhereClauseTranslator(_resolver,null);

            var whereClause = whereTranslator.Translate(lambda.Body, _builder,lambda.Parameters[0].Name);
            _builder.AddWhereClause(whereClause);
        }