DataServiceQuery LINQ查询ToList()返回最后一个条目的副本 [英] DataServiceQuery LINQ query ToList() return copy of last entry

查看:174
本文介绍了DataServiceQuery LINQ查询ToList()返回最后一个条目的副本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的读者,



我目前正在尝试访问SAP Gateway ODATA服务的结果,但有一种特殊方法似乎不符合.net结果预期。下面的代码是我正在使用的,结果是所有条目都填充了最后一个条目的值。 LINQPad显示两个结果;在richtext视图中,它为我提供了所有条目的正确值,并且Datagrids结果类似于我的代码中的问题(最后一个条目的多个副本)



Dear reader,

I'm currently trying to access the results of a SAP Gateway ODATA service but one particular method doesn't seem to comply with .net result expectations. The code below is what I'm using and the result is that all the entries are filled with the values of the last entry. LINQPad shows two results; in the richtext view it gives me the correct values of all the entries and the Datagrids result resembles the problem I have in my code (multiple copies of last entry)

CRM_Open_Dagen.ZCRM_EVENTS01_SRV.ZCRM_EVENTS01_SRV ZCRM_EVENTS01_SRV =
    Data.ZCRM_EVENTS01_SRV.Get_ZCRM_EVENTS01_SRV();

DataServiceQuery<CRM_Open_Dagen.ZCRM_EVENTS01_SRV.SOptions> SOptions = ZCRM_EVENTS01_SRV.SOptionsSet;

List<CRM_Open_Dagen.ZCRM_EVENTS01_SRV.SOptions> ListSOptions =
    (from s in SOptions
     where s.Show == Category
     select s).ToList();

return ListSOptions;





任何人都知道如何:

1)我可以查看odata的语法结果?

2)我如何解决这个问题?



祝你好运,谢谢,
$ b $bRémy



Anyone an idea how:
1) I can check the syntax of the odata result?
2) How I can tackle this problem?

Best regards and thanks,
Rémy

推荐答案

找出问题所在:

SAP Gateway数据模型中定义了一个KEY,但返回的数据不包含关键。不知何故,默认密钥是每个条目的空字符串,因此在添加每个条目时,将更新包含特定密钥''的所有数据,因此最后一个条目用最后一个条目的数据更新所有行。



Duh ....
Found out what the problem is:
There was a KEY defined in the SAP Gateway datamodel, but the returned data didn't contain a key. Somehow the default key was an empty string for each entry, so with the adding of each entry all the data containing the specific key '' would be updated, hence the last entry updated all rows with the data of the last entry.

Duh....


这篇关于DataServiceQuery LINQ查询ToList()返回最后一个条目的副本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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