没有绑定多个Expand语句的对象 [英] Objects not bound with multiple Expand statements

查看:73
本文介绍了没有绑定多个Expand语句的对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有以下数据(简化)。
Session:
SessionID,
Title
标签:
TagID,
描述
(只是绑定):
Session2Tags:
TagID,
SessionID

使用EntityFramwork我得到以下类:
Session
Title(String)
Tags (集合)
标签
描述(字符串)
会话(集合)

事物 - 会话可以属于多个"类别"。 (标签) - 并且在一个类别下我可以有多个会话。

我的应用程序显示带有可能标签的组合框。
当我选择一个标签时,我填充的列表框中包含此标签下的会话。

这适用于
combobox1.DataContext = ctx.Tags.Expand(" Session");

我可以在表单中使用EF(没有数据服务)
combobox1.DataContext = ctx.Tags.Include(" Session");

所以现在我想稍微扩展一下,并提供第三个组合框,显示会话注册的标签。使用EF我做:
combobox1.DataContext = ctx.Tags.Include(" Session")。包含(" Session.Tags");
它运行正常!!!

现在我用这种方式尝试使用数据服务:
combobox1.DataContext = ctx.Tags.Expand(" Session")。Expand(" Session / Tags");

现在这些东西只能"完成一半"。

第一印象:
我有一个(顶部列出的)标签"All" - 在每个会话中标记。
在这种情况下,只有组合框中的第一个标记具有"会话"。条目。
所有其他人都有一个有效的Sessions对象 - 但是Count == 0。

第二印象:
我放置了"All"在Sorting中向后标记(称之为XAll)。
不是我得到了一些绑定到标签的Sessions - 但它看起来好像仅在Sessions.Tags中使用了所有类型的标签之后绑定。

示例:标签可用:Kind1,Kind2,Kind3
Session1 - 标签:Kind1
Session2 - 标签:Kind2,Kind3
Session3 - 标签:Kind1,Kind3
Session4 - 标签:Kind2

在这种情况下,我获得标签Kind1和Kind2的会话。
会话不受Kind3的约束(看起来这与Kind3已经存在于Kind2下的Session中这一事实有关) 。所以标签看起来像这样:
Tag_Kind1:Sessions(1,3)
Tag_Kind2:Sessions(2,4)
Tag_Kind3:Sessions(Count == 0)

如果我有"All_Tag"在顶部它看起来像这样。
Tag_Kind_ALL:会话(1,2,3,4)
Tag_Kind1:会话(计数== 0)
Tag_Kind2:会话(计数== 0)
Tag_Kind3:会话(计数== 0)


通过观察服务(给出URI的组合:combobox1.DataContext = ctx.Tags.Expand("Session")。展开("会话/标签") ;);语句生成我得到的数据应该是这样的。
看起来像一个
http://localhost:2128/XDS.svc/Tags()?$expand=Sessions,Sessions/Tags
它为我提供了正确的数据。

所以似乎绑定被破坏了 - 或者它是否是某种"不同的"绑定,我必须改变一些东西。
数据没问题 - 它适用于本地实体框架。
它也使用该服务 - 只要我只扩展一个"子元素"(combobox1.DataContext = ctx.Tags.Expand("Session");

但是一旦扩展第二个元素它就会失败。点击< br>任何帮助都会很棒!!

Manfred

解决方案

跟进。

看来这有与执行时间左右有关。
我尝试了一下,找到了


















// siE == my context
siE.MergeOption = 系统 .Data.Services.Client.MergeOption.AppendOnly;
var xR = 来自 y(" Sessions")。展开(" Sessions / Tags")
选择Ÿ;
cbTags.DataContext = xR ; //失败

Hi,

I have the following data (reduced).
Session:
   SessionID,
   Title
Tags:
    TagID,
    Description
(Just to bind):
Session2Tags:
    TagID,
    SessionID

With EntityFramwork I get the following classes:
Session
   Title (String)
    Tags (Collection)
Tags
    Description (String)
    Sessions(Collection)

The thing - a session could belong to multiple "categories" (Tags) - and under one Category I can have multiple sessions.

My app displays a combobox with the possible Tags.
When I select a Tag than I fill a listbox with the Sessions under this tag.

This works fine with
combobox1.DataContext=ctx.Tags.Expand("Session");

I can do the same with EF (without data services) in the form
combobox1.DataContext=ctx.Tags.Include("Session");

So now I wanted to expand the thing a bit and provide a third combobox which shows the tags under which a session is registered.
With EF I do:
combobox1.DataContext=ctx.Tags.Include("Session").Include("Session.Tags");
And it works fine!!!

Now I tried the same with data services in this way:
combobox1.DataContext=ctx.Tags.Expand("Session").Expand("Session/Tags");

Now the things work only "half the way".

First impression:
I have a (top listed) tag "All" - which tags every session.
In this situation only the first tag in the combobox has "Sessions" entries.
All other have a valid Sessions object - but Count==0.

Second impression:
I placed the "All" tag backwards in Sorting (calling it XAll).
Not I get some Sessions bound to the Tags - but it looks as if the are bound only until all kind of Tags have been used in Sessions.Tags.

Example:
Tags available: Kind1, Kind2, Kind3
Session1 - Tags: Kind1
Session2 - Tags: Kind2, Kind3
Session3 - Tags: Kind1, Kind3
Session4 - Tags: Kind2

In this situation I get Sessions for the Tags Kind1 and Kind2.
Sessions is not bound to Kind3 (it seems as this has something to do with the fact that Kind3 already exists in a Session under Kind2).
So the Tags look like this:
Tag_Kind1: Sessions (1,3)
Tag_Kind2: Sessions(2,4)
Tag_Kind3: Sessions(Count==0)

If I have the "All_Tag" on Top it would look like this.
Tag_Kind_ALL: Sessions (1,2,3,4)
Tag_Kind1: Sessions(Count==0)
Tag_Kind2: Sessions(Count==0)
Tag_Kind3: Sessions(Count==0)


By watching the service (giving the URI the combobox1.DataContext=ctx.Tags.Expand("Session").Expand("Session/Tags"); statement produces I get the data like it should be.
It looks like
http://localhost:2128/XDS.svc/Tags()?$expand=Sessions,Sessions/Tags
And it provides me with the correct data.

So it seems as if the binding is broken - or if it is some kind of "distinct" binding where I have to change something.
The data is OK - it works well with local Entity Framework.
It also works with the service - as long as I expand only one "subelement" (combobox1.DataContext=ctx.Tags.Expand("Session");

But it fails as soon as I expand the second element.

Any help would be great!!

Manfred

解决方案

Follow UP.

It seems as this has something to do with execution time or so.
I tried around a bit more and found

//siE==my context  
siE.MergeOption = System.Data.Services.Client.MergeOption.AppendOnly;  
var xR = from y in siE.Tags.Expand("Sessions").Expand("Sessions/Tags")  
         select y;  
cbTags.DataContext = xR; //fails  
 


这篇关于没有绑定多个Expand语句的对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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