Reputation: 205
I have created a Model and i want to access model data annotation like DisplayName
.
I have access model through WCF service layer. But WCF service remove all the Data annotation of the model.
[DisplayName("Student Name")]
public virtual string StudentName
{
get
{
return this.m_StudentName;
}
set
{
this.m_StudentName= value;
}
}
I want to access Display Name in the View but always I get null
value in the DisplayName
method in through the Property
Upvotes: 2
Views: 158
Reputation: 77285
A WCF service does not remove anything. However, building a service reference is making a copy of all the classes you have. And that copy is the smallest set neccessary to run the service.
If you need your full classes, put all those classes and interfaces you want shared into a common library that both your service and your client reference. This is commonly called a contract assembly
. You can then either call the service directly through code or if you want to keep the wizard, you can use the checkbox that says "use classes in this project" when generating new types.
Upvotes: 2