How to pass a NULL value to a WCF Data Services' service operation?

烂漫一生 提交于 2019-12-11 18:19:41

问题


I have a WCF data services' service operation such as

[WebGet(UriTemplate = "GetData")]
public IQueryable<string> GetData(int code, int deviceid, int groupId, DateTime dateTimeFrom, DateTime dateTimeTo)
{ ...
}

I am calling this service operation by sending a HTTP request to the server in this format:

http://localhost:6000/GetData?code=0&deviceId=1&groupId=0L&dateTimeFrom=datetime'2013-01-31T15:36:50.904'&dateTimeTo=datetime'2012-02-01T15:36:50.904'

and it is working like a charm.

Now I want to pass a NULL value as one of the parameters. How do I do that? Do I need to use nullable types such as "Int?" in the service operation declaration? How do I encode the NULL value in the URI?


回答1:


Yes - you need to declare the parameter as nullable. Then you can simply omit the parameter (if it's nullable it will be treated as null then).



来源:https://stackoverflow.com/questions/10849962/how-to-pass-a-null-value-to-a-wcf-data-services-service-operation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!