문제

Inside the AdventureWorks database we have Individuals, Contacts and Customers. These 3 tables are related. My goal is to get the FirstName, LastName and Email up on the Customers when I call them.

Is there a way to resolve this with mappings?

Thanks in advance. Kyor

EDIT: Structure: Structure of the table

도움이 되었습니까?

해결책

I can think of two ways:

1) Using Include()

 var customers = context.Customer.Include("Individual.Contact");

Then you can access the properties by: customers.First().Individual.Contact.FirstName;

2) Projecting to a new Type

  var customers = from c in context.Customer
                  select new NewCustomerType
                  {
                    Customer = c,
                    FirstName = c.Individual.Contact.FirstName,
                    LastName = .Individual.Contact.LastName,
                    .
                    .
                    .
                  };
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top