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 997599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T07:03:38+00:00 2026-05-16T07:03:38+00:00

How do I get properties in my BLL passed down to a ModeView. For

  • 0

How do I get properties in my BLL passed down to a ModeView. For example, I have this class in a separate Class Library:

[MetadataType(typeof(PersonMetaData))]
public partial class Person
{        
    [Bind(Include = "PersonId,DepartmentId,FirstName,LastName,Active,DateAdded,DateDeleted")]
    public class PersonMetaData
    {           
        public object PersonId { get; set; }

        public object DepartmentId { get; set; }

        public object FirstName { get; set; }

        public object LastName { get; set; }

        public Department PersonDepartment { get; set; }

        public string FullName()
        {
            return string.Format("{0} {1}", FirstName, LastName);
        }
    }
}

My ViewModel looks like this:

public class PersonViewModel
{
    public int PersonId { get; set; }
    public string FullName{ get; set; }
    public string PersonDepartment { get; set; }
}

When I generate a new “View” strongly-typed to the PersonViewModel and set as “List” View Content….the page is generated, but FullName is not coming through.

I created the PersonDepartment property because I want to display the Department Name the person is in. I have a Department Class set up similarly. For example, I want to be able to do something like “PersonDepartment.DepartmentName” that displays the department name on the page.

I am using a DBML (Linq To SQL), so the partial classes are extending from the auto-generated classes.

I am not sure how to get FullName property filled and passed to ViewModel and get Department properties connected to the Person information being passed. Any help would be greatly appreciated.

  • 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-05-16T07:03:38+00:00Added an answer on May 16, 2026 at 7:03 am

    You have mentioned that you are using AutoMapper. In your model FullName is a method and not a property. AutoMapper won’t map automatically to methods. According to the conventions you could prefix your method name with Get to make this to work:

    public string GetFullName()
    {
        return string.Format("{0} {1}", FirstName, LastName);
    }
    

    This will be mapped to the FullName property in the view model. Another option is to explicitly declare how the mapping is done:

    Mapper.CreateMap<Person, PersonViewModel>()
          .ForMember(
              dest => dest.FullName, 
              opt => opt.MapFrom(src => src.FullName())
          );
    

    As far as the department name property is concerned I would recommend you modify your model so that instead of a DepartmentId property it has directly a property called Department containing the id and the name which will allow you to map them easily in your view model. If you cannot modify your model this way you could have the Department property in the view model populated directly by the repository and not by AutoMapper.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

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.