Beispiel #1
0
        private string Translate(Expression expression)
        {
            var translator = new WiqlQueryTranslator();
            WiqlQueryTranslationResult result = translator.Translate(expression, AsOf);

            return(result.ToString());
        }
Beispiel #2
0
        /// <summary>
        /// Builds the query.
        /// </summary>
        /// <param name="server">The server.</param>
        /// <param name="project">The project.</param>
        /// <param name="asOf">As of.</param>
        /// <returns></returns>
        public WiqlQueryTranslationResult BuildQuery(DateTime?asOf)          //Microsoft.TeamFoundation.Client.TeamFoundationServer server, Microsoft.TeamFoundation.WorkItemTracking.Client.Project project,
        {
            if (_query != null)
            {
                return(_query);
            }
            StringBuilder builder = new StringBuilder();

            builder.Append("SELECT ");
            if (_selectFieldList == null)
            {
                builder.Append(DEFAULTCOLUMN);
            }
            else
            {
                builder.AppendFormat("[{0}]", String.Join("], [", _selectFieldList.ToArray()));
            }
            builder.AppendLine();
            builder.AppendLine("FROM WORKITEMS ");
            if (_whereList.Count > 0)
            {
                builder.Append("WHERE ");
                if (_whereList.Count == 1)
                {
                    builder.AppendLine(_whereList[0]);
                }
                else
                {
                    builder.AppendFormat("({0})", String.Join(") AND (", _whereList.ToArray()));
                    builder.AppendLine();
                }

                //builder.Append("(");
                //builder.Append(String.Join(") AND (", _whereList.ToArray()));
                //builder.AppendLine(")");
            }
            if (_orderbyList.Count > 0)
            {
                builder.Append("ORDER BY ");
                builder.AppendLine(String.Join(", ", _orderbyList.ToArray()));
            }
            if (asOf.HasValue)
            {
                builder.AppendFormat(" ASOF {0}", GenerateMacro(asOf.Value));
            }
            string wiql = builder.ToString();

            _query = new WiqlQueryTranslationResult
            {
                Wiql    = wiql,
                Context = _macroDictionnary
            };
            //_query = new WorkItemQuery(server, project, "LINQ Query", wiql, _macroDictionnary);

            return(_query);
        }
Beispiel #3
0
        private object InternalExecute(Expression expression, Func <WIT.WorkItemCollection, WIT.WorkItem> selector)
        {
            var translator = new WiqlQueryTranslator();
            WiqlQueryTranslationResult result = translator.Translate(expression, AsOf);

            if (selector == null)
            {
                return(Store.Query(result.Wiql, result.Context));
            }
            else
            {
                return(selector(Store.Query(result.Wiql, result.Context)));
            }
        }
Beispiel #4
0
        //Microsoft.TeamFoundation.Client.TeamFoundationServer server, Microsoft.TeamFoundation.WorkItemTracking.Client.Project project,
        /// <summary>
        /// Builds the query.
        /// </summary>
        /// <param name="server">The server.</param>
        /// <param name="project">The project.</param>
        /// <param name="asOf">As of.</param>
        /// <returns></returns>
        public WiqlQueryTranslationResult BuildQuery(DateTime? asOf)
        {
            if (_query != null)
            {
                return _query;
            }
            StringBuilder builder = new StringBuilder();
            builder.Append("SELECT ");
            if (_selectFieldList == null)
            {
                builder.Append(DEFAULTCOLUMN);
            }
            else
            {
                builder.AppendFormat("[{0}]", String.Join("], [", _selectFieldList.ToArray()));
            }
            builder.AppendLine();
            builder.AppendLine("FROM WORKITEMS ");
            if (_whereList.Count > 0)
            {
                builder.Append("WHERE ");
                if (_whereList.Count == 1)
                {
                    builder.AppendLine(_whereList[0]);
                }
                else
                {
                    builder.AppendFormat("({0})", String.Join(") AND (", _whereList.ToArray()));
                    builder.AppendLine();
                }

                //builder.Append("(");
                //builder.Append(String.Join(") AND (", _whereList.ToArray()));
                //builder.AppendLine(")");
            }
            if (_orderbyList.Count > 0)
            {
                builder.Append("ORDER BY ");
                builder.AppendLine(String.Join(", ", _orderbyList.ToArray()));
            }
            if (asOf.HasValue)
            {
                builder.AppendFormat(" ASOF {0}", GenerateMacro(asOf.Value));
            }
            string wiql = builder.ToString();

            _query = new WiqlQueryTranslationResult
            {
                Wiql = wiql,
                Context = _macroDictionnary
            };
            //_query = new WorkItemQuery(server, project, "LINQ Query", wiql, _macroDictionnary);

            return _query;
        }