我希望在我的域服务中使用类似于以下内容的方法:
public SystemState GetSystemStatus() { return new SystemStatus { InterestingStatusValue1 = 1223, OtherInterstingStatusValue = "abc", } }
那不管用。不会为Silverlight客户端应用程序自动生成任何内容。如果我让这个方法成为一个IQueryable方法,那么我会在客户机上生成一些东西。我将获得一个SystemStates属性和一个context对象的查询方法。
难道没有办法让这成为一个简单的WCF调用吗?我想我可以为我的RIA网站提供一个支持WCF Silverlight的服务,然后设置一个服务引用(这不对吗?)(为什么我在Silverlight应用程序中看不到服务引用?)
乍一看,RIA服务似乎强制使用一种非常以数据为中心的/简单的CRUD,这对表编辑器来说很好,但对于那些在datagrid上拖后腿的LOB应用程序来说就没那么多了。
使用属性只能返回一个实体(假设SystemState是您的实体):
[Query(IsComposable = false)] public SystemState GetSystemStatus() { return new SystemStatus { InterestingStatusValue1 = 1223, OtherInterstingStatusValue = "abc", } }
EntityQuery<SystemState> GetSystemStatusQuery()
如果要在服务器上执行操作,请尝试使用[Invoke]属性。前任:
[Invoke] public SystemState GetSystemStatus() { return new SystemStatus { InterestingStatusValue1 = 1223, OtherInterstingStatusValue = "abc", } }