S
S
stcmd042362016-07-04 16:30:09
C++ / C#
stcmd04236, 2016-07-04 16:30:09

How to use data annotations in c# web api?

Good afternoon! in MVC, you can control the visibility of fields using attributes from the System.ComponentModel.DataAnnotations space. How can you do the same with asp .net web api?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anatoliy Mikhailov, 2016-07-05
@stcmd04236

Alternatively, you can mark the class as [DataContract], set the DataMember to the required fields, and do not mark the fields that should be invisible (well, or for clarity, mark IgnoreDataMember)

P
Peter, 2016-07-04
@petermzg

So write your own logic to handle this type of attributes.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question