如何在 WCF 数据服务对象上创建依赖于服务器状态的属性?
我正在尝试创建一个 WCF 数据服务,它返回看起来有点像我的 POCO 的对象;它们的不同之处在于它们具有在调用查询时计算的单个属性。
换句话说,我有一张 POCO 胶片。我希望能够查询电影,它为我提供了每个电影都添加了属性“IsAllowedToWatch”的电影。 “IsAllowedToWatch”的值由我的身份验证状态和当前观看该电影的用户数量决定。
我正在使用代码优先 EF4 和 WCF 数据服务。谁能建议最好的方法?
I am trying to create a WCF Data Service that returns objects that look somewhat like my POCOs; they differ insofar as they have a single property which is computed when a query is called.
In other words say I have a POCO Film. I want to be able to query for Films which gives me Films with each with an added property 'IsAllowedToWatch'. The value of 'IsAllowedToWatch' is determined by my authentication state and the number of users currently watching that film.
I'm using Code-First EF4 and WCF Data Services. Can anyone suggest the best way of doing this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我已经解决了这个问题,但解决方案相当复杂。我必须使用一个自定义 IQueryProvider 在我的自定义业务类型和数据库类型之间进行调解。一切都变得相当丑陋!
I've solved this problem but the solution was rather convoluted. I had to employ a custom IQueryProvider that mediated between my custom business type and the database type. It all got rather ugly!