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.