开发者

WCF RIA Services for POCO as a query parameter

I define a method below in a DomainService class but get a compiler e开发者_开发技巧rror: Parameter 'objectType' of domain operation entry 'GetPropertiesByGuiObject' must be one of the predefined serializable types.

public IQueryable<PropertyType> GetPropertiesByGuiObject(ObjectType objectType)
{
  return properTypeDA0.GetPropertiesByGuiObject(objectType).AsQueryable();
}

ObjectType is a POCO class I defined . I have added the [Serializable] or [DataContract] attribute to the ObjectType class definition but the error still exist. Can the parameter of a domain operation entry be a POCO object?


Are you using VS 2010 SP1? On the first version of WCF RIA Services (with VS 2010 RTM), it did not have support for complex types, but in the SP1 version, this support was added. You can find more information at http://msdn.microsoft.com/en-us/library/gg602753 and http://blogs.msdn.com/b/digital_ruminations/archive/2010/10/28/complextypes-in-ria-services.aspx.


Unfortunately, WCF RIA services (atleast the current version) doesn't allow you to pass any complex type or POCO's as parameters for you Get queries. 'Predefined' here means a small set of types like string, guid, etc.

I usually pass an ID or some reference to bypass this.

Hope this answers your question.

Thanks

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜