Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9247183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:40:08+00:00 2026-06-18T09:40:08+00:00

I want to add a DisplayAttribute to the Client entity (from another project), but

  • 0

I want to add a DisplayAttribute to the Client entity (from another project), but don’t want to pollute my entity with attributes specific to MVC or a UI layer. So I planned to add the DisplayAttribute by applying a metadata class to a view model inheriting from the entity

If I inherit from the Client entity and then try to use the MetadataTypeAttribute to add a display attribute, it doesn’t show up in the browser. Does anyone know how I can achieve the separation and the functionality of being able to add metadata to my entities?

The Client entity class:

public class Client
{
    private string firstName;

    private string lastName;

    private string homeTelephone;

    private string workTelephone;

    private string mobileTelephone;

    private string emailAddress;

    private string notes;

    public Title Title { get; set; }

    public string FirstName
    {
        get { return this.firstName ?? string.Empty; }

        set { this.firstName = value; }
    }

    public string LastName
    {
        get { return this.lastName ?? string.Empty; }

        set { this.lastName = value; }
    }

    public string FullName
    {
        get
        {
            List<string> nameParts = new List<string>();

            if (this.Title != Title.None)
            {
                nameParts.Add(this.Title.ToString());
            }

            if (this.FirstName.Length > 0)
            {
                nameParts.Add(this.FirstName.ToString());
            }

            if (this.LastName.Length > 0)
            {
                nameParts.Add(this.LastName.ToString());
            }

            return string.Join(" ", nameParts);
        }
    }

    public Address Address { get; set; }

    public string HomeTelephone
    {
        get { return this.homeTelephone ?? string.Empty; }

        set { this.homeTelephone = value; }
    }

    public string WorkTelephone
    {
        get { return this.workTelephone ?? string.Empty; }

        set { this.workTelephone = value; }
    }

    public string MobileTelephone
    {
        get { return this.mobileTelephone ?? string.Empty; }

        set { this.mobileTelephone = value; }
    }

    public string EmailAddress
    {
        get { return this.emailAddress ?? string.Empty; }

        set { this.emailAddress = value; }
    }

    public string Notes
    {
        get { return this.notes ?? string.Empty; }

        set { this.notes = value; }
    }

    public Client()
    {
        this.Address = new Address();
    }
}

The ClientViewModel view model class:

[MetadataType(typeof(ClientMetaData))]
public class ClientViewModel : Client
{
    internal class ClientMetaData
    {
        [Display(ResourceType = typeof(ResourceStrings), Name = "Client_FirstName_Label")]
        public string FirstName { get; set; }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T09:40:10+00:00Added an answer on June 18, 2026 at 9:40 am

    I think you have change the typeof parameter to:

    [MetadataType(typeof(ClientViewModel.ClientMetaData))]
    public class ClientViewModel : Client
    {
        internal class ClientMetaData
        {
            [Display(ResourceType = typeof(ResourceStrings), Name = "Client_FirstName_Label")]
            public string FirstName { get; set; }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want add new user from another script and I need create password for
I want to add same additional fields to my form, but I don't want
In my project I want to add an object in a specific position of
I want add multiple images in my own project like 7 images but in
I want add this bundle but I don't know how install it in my
I want add UIGestureRecognizerDelegate to UIWebView,but failed. if [self.view addsubView:webView]; So UIWebView is ok,but
I want add new Feed item on entity persist and update. I write this
I have problem, when I want add Node to my GUI from other Thread.
I have numbers in javascript from 01(int) to 09(int) and I want add 1(int)
I want to add Gon ( https://github.com/gazay/gon ) to my activeadmin but I need

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.