通过预处理替换RIA查询 [英] Replace RIA query via preprocess

查看:65
本文介绍了通过预处理替换RIA查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对此进行了一些研究,不确定是否可行。大多数相关搜索都是Silverlight,或者不涉及将HTML客户端的参数传递给RIA服务器项目。

I have researched this a bit and am not sure if it's possible. Most related searches are either Silverlight or don't involve passing a param from the HTML client to the RIA server project.

我的项目具有RIA服务设置,可以通过一个查询我的Jira服务器API。它连接和拉取数据没问题。但是我需要将其配置为从HTML客户端传递参数(用户选择具有param值的'selectedItem')到
RIA项目。我们的想法是将已经在Jira中设置的所有用户JQL(Jira查询语言)拉出来并将它们传递给RIA服务以获取结果。基本上是动态查询。之后,我将记录导入我的LS数据库,用于
流程的其他部分。请注意,Jira服务器中有数千个项目,因此只需拉动所有项目并使用过滤器来隔离数据集就不是一种选择。

My project has the RIA service setup to query my Jira server via a an API. It connects and pulls data no problem. However I need to configure it to pass a parameter from the HTML client (the 'selectedItem' the user selects which has the param value) to the RIA project. The idea is to pull all the users JQL's (Jira Query Language) already setup in Jira and pass them to the RIA service to pull the results. Basically a dynamic query. After which I will import the records into my LS database for other parts of the process flow. Note, there are thousands of items in the Jira server, so simply pulling all and using filters to isolate the dataset is not an option.

我理解LS默认情况下不会这样做不允许使用参数(RIA查询必须是无参数的)。

I understand LS won't do this by default as parameters are not allowed (RIA queries must be parameter-less).

为了解决这个问题,我试图在预处理方法中重写基本查询。然而,它看起来像一个排序问题,其中RIA查询基于我在调试中遵循的断点而先于先例。

To work around this, I have attempted to re-write the base query in the pre-process method. However it looks like a sequencing issue where the RIA query takes precedent based off the breakpoints I have followed in debugging.

这甚至可能还是我在追求毫无意义的努力?提前致谢

Is this even possible or am I pursuing a pointless endeavor? Thanks in advance

// RIA service Query
        [Query(IsDefault = true)]
        public IQueryable<JiraIssue> getJiraIssues()
        {
            jira.Connect("https://my-jira-server", jUserID, jPassword);
            var fltrs = jira.GetFilters();
            var jql = fltrs.Where(x => x.Name == "MyCustom JQL in Jira").First().JQL;   // the default query param
            var issues = jira.SearchIssues(jql, 700); // this returns the collection based off the 'jql' parameter
            var materializedIssues = from i in issues
                                         //where i.Fields.CustomFields["customfield_10002"] == null
                                     select new JiraIssue
                                     {
                                         Key = i.Key,
                                         Summary = i.Summary,
                                         Description = i.Description,
                                         StoryPoints = i.Fields.CustomFields["customfield_10002"] == null ? "No Value" : i.Fields.CustomFields["customfield_10002"].Value,
                                         IssueType = i.IssueType.Name,
                                         Rank = i.Rank,
                                         Status = i.Status.Name,
                                         Reporter = i.Reporter.Name
                                         //Parent = i.Parent.Key == null ? "No Value" : i.Parent.Key
                                         //i.Subtasks != null ? (i.Subtasks.Where(x=>x.Key != null).First().Key == null ? "nothing" : i.Subtasks.First().Key) : "nothing",
                                         // (from s in i.Subtasks
                                         //group s by s.Key into g
                                         //select new sTasks {
                                         //    sTsk = String.Join(",", g.Select(x=>x.Key))
                                         //}),
                                         //Severity = i.Severity,
                                         //Sprint = i.Sprint.Name,

                                     };
            return materializedIssues.AsQueryable();
        }


// Preprocess Query public partial class JiraAPIService { partial void JQL_JiraList_PreprocessQuery(string Parameter, ref IQueryable<JiraIssue> query) { string jUserID = "<MyID>"; string jPassword = "<Password>"; Jira.SDK.Jira jira = new Jira.SDK.Jira(); jira.Connect("https://my-jira-server", jUserID, jPassword); var issues = jira.SearchIssues(Parameter, 700); // provide a new collection result based on the

//'参数'值提供新的收集结果

var materializedIssues = from i in issues
//其中i.Fields.CustomFields [" customfield_10002"] == null
选择新的JiraIssue
{
Key = i.Key,
摘要= i.Summary,
说明= i.Description ,
StoryPoints = i.Fields.CustomFields [" customfield_10002"] == null? "无价值" :i.Fields.CustomFields [" customfield_10002"]。值,
IssueType = i.IssueType.Name,
Rank = i.Rank,
Status = i.Status.Name,
Reporter = i.Reporter.Name
};
query = materializedIssues.AsQueryable();
}
}

// 'Parameter' value var materializedIssues = from i in issues //where i.Fields.CustomFields["customfield_10002"] == null select new JiraIssue { Key = i.Key, Summary = i.Summary, Description = i.Description, StoryPoints = i.Fields.CustomFields["customfield_10002"] == null ? "No Value" : i.Fields.CustomFields["customfield_10002"].Value, IssueType = i.IssueType.Name, Rank = i.Rank, Status = i.Status.Name, Reporter = i.Reporter.Name }; query = materializedIssues.AsQueryable(); } }

推荐答案

您绝对可以使用HTML客户端使用的参数创建RIA查询方法。 诀窍是如果所有参数都不是字符串参数且参数只能是简单的数据类型,那么它们必须是可空的。



此外,你必须始终有一个默认值每个RIA实体的无参数查询,即使您不需要它也只为该默认查询返回一个空数组。



换句话说,要有一个查询方法包含特定实体的参数,您需要在RIA服务中创建至少两种查询方法:



1.默认查询方法(标有[查询(IsDefault = true)]属性)不带参数

2.包含参数的其他查询方法(标有[Query(IsDefault = false)] ...

You can absolutely create RIA query methods with parameters that are consumed by the HTML client.  The trick is that all the parameters must be nullable if they are not string parameters and the parameters can only be simple data types.

Also, you must always have a default parameterless query for each RIA entity, even if you simply return an empty array for that default query if you don't need it.

In other words, to have a query method with parameters for a specific entity, you need to create at least two query methods in your RIA service:

1. The default query method (marked with the [Query(IsDefault = true)] attribute) without parameters
2. The other query method that contains parameters (marked with [Query(IsDefault = false)]...

希望这会有所帮助。


这篇关于通过预处理替换RIA查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆