[英]IPP .NET c# SDK allows query filters, but this does not reduce payload?
Referencing the following IPP Documentation: 参考以下IPP文档:
https://developer.intuit.com/docs/0025_quickbooksapi/0055_devkits/0150_ipp_.net_devkit_3.0/query_filters https://developer.intuit.com/docs/0025_quickbooksapi/0055_devkits/0150_ipp_.net_devkit_3.0/query_filters
I made the assumption that the following code using the Linq Extentions Projection would alter the request and reduce the payload of the response by only querying for the requested fields and only including those fields (narrow result set) in the response: 我假设使用Linq Extensions Projection的以下代码将仅通过查询所请求的字段并且仅在响应中包括那些字段(窄结果集)来更改请求并减少响应的有效负载:
public List<ShortAccount> GetFullShortAccountList(bool logRequestResponse)
{
var accounts = new List<ShortAccount>();
var accountQueryService = new QueryService<Account>
(GetIppServiceContext(logRequestResponse));
var selected = accountQueryService.Select(a => new { a.Id, a.Name });
foreach (var account in selected)
{
accounts.Add(new ShortAccount { Id = account.Id, Name = account.Name });
}
return accounts;
}
Now the behavior of this method is as expected, but if I look at the request/response logs (or the actual request and response using Fiddler) the request doesn't change -- it is still "Select * from Account", and the response still includes all the other properties in the Account entity. 现在,此方法的行为符合预期,但是如果我查看请求/响应日志(或使用Fiddler的实际请求和响应),则请求不会更改-它仍然是“从帐户中选择*”,并且响应仍包括帐户实体中的所有其他属性。
In other words, the payload is not reduced one iota. 换句话说,有效载荷不会减少一个iota。
Am I doing something wrong here? 我在这里做错什么了吗? Or do I just understand this incorrectly? 还是我只是理解不正确?
How can I use the SDK to generate a query that would look more like "Select Id, Name from Account", and only return that result set? 如何使用SDK生成看起来更像“从帐户中选择ID,名称”的查询,并且只返回该结果集?
Related question -- if this mode of query filtering does not reduce the payload, what is its purpose? 相关问题-如果这种查询过滤模式不会减少有效负载,其目的是什么? You might as well get the whole shebang and just take the fields you need? 您不但可以获取全部所需费用,还可以选择所需的字段?
Thanks in advance. 提前致谢。
That's right @Barrick. 没错,@ Barrick。 The implementation of our query providers is not exactly the same as the standard LINQ. 我们的查询提供程序的实现与标准LINQ并不完全相同。 So, Stephan, that's the issue. 所以,斯蒂芬,这就是问题所在。
If you just want to get specific fields I would suggest you to use IDSQuery like: 如果您只想获取特定字段,建议您使用IDSQuery:
QueryService<Account> AccQueryService22 = new QueryService<Account>(context);
var t13 = AccQueryService22.ExecuteIdsQuery("Select Id, Name From Account Where Active in (true, false)");
I will forward the feedback to our team. 我会将反馈转发给我们的团队。
Thanks! 谢谢!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.