开发者

When Collection Propert Repesents History, What Binding Strategy for the most Recent Item?

开发者 https://www.devze.com 2023-02-10 00:11 出处:网络
I have an entity in EF4 that represents a device in the field being tested (Device). This entity has a property called DeviceStatuses with three fields (key1, key2, datetime). It is a bridge table to

I have an entity in EF4 that represents a device in the field being tested (Device). This entity has a property called DeviceStatuses with three fields (key1, key2, datetime). It is a bridge table to the Status table. It is used to keep a hist开发者_开发问答ory of the statuses an individual device has been set to. So the navigation property Device.DeviceStatuses.Status Gives me a collection of DeviceStatuses but only the DeviceStatus with max(datetime) is the one I am interested in.

My question is how would I go about working with this? Could I create a custom Property in the Device entity? Is there a way in the XAML of my application to bind only to the status I want?


Because of the type of collection returned I was not able to use the {Binding Device.DeviceStatuses[0].Status} syntax. I ended up writing a custom converter that grabbed the most recent value and returned said value.

0

精彩评论

暂无评论...
验证码 换一张
取 消