简体   繁体   中英

Expose few property of class at runtime in WCF service

I have a class for ex User class in WCF service, In that i have 10 properties like Fname, Lname, ServiceStatus, ErrorMessage etc.

Now there is method in service who retrieve the user info by giving the valid Json input and gives output in Json format (Here I am exposing user class object).

Now my problem: - Now when i expose this user class then i got the all properties in json output. There were few cases where i don't want to expose all properties. In some cases I want to expose only two properties, or in few cases all properties. I want to do this to make JSON Output more clear.

Is it Possible in WCF? Please help.

不要将[DataMember ]属性放置或不向您不想公开的属性添加[IgnoreDataMember]属性。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM