2011-10-24 2 views
0

다른 고객, 주소 및 계정 유형의 3 가지 일반 목록이 있다고 가정 해 봅니다. 어떻게 그들을 'CustomerProfile'유형의 일반적인 목록으로 결합합니까? 당신이 할 수없는,다른 유형의 일반 목록을 하나의 일반 사용자 정의 유형 목록에 결합하려면 어떻게합니까?

<CustomerProfile> 
<Customer>  
    <customerId> 
    <titleId> 
     <firstName> 
     <middleName> 
     <maritalStatusId> 
</Customer> 
<Address> 
     <addressId> 
     <customerId> 
     <addressTypeId> 
     <postCode> 
     <geoCodeLattitude> 
     <geoCodeLongitude> 
</Address> 
<Account> 
    <accountID> 
     <accountDesc> 
     <accountStatusID> 
     <joinDate> 
     <insertDateTime> 
</Account> 
</CustomerProfile> 
+0

'x has' 패턴이 아니고'x is' 패턴이기 때문에 인터페이스로 이동해야합니다 –

+0

XML은 어디서 들어 옵니까? 귀하의 질문은 현재 명확하지 않습니다 ... 당신은 CustomerProfile 클래스가 있습니까? http://tinyurl.com/so-hints –

답변

1

짧은 답변 :

Example: 
Public class Customer 
{  
    long customerId{ get; set; }  
    int titleId{ get; set; } 
     string firstName{ get; set; } 
     string middleName{ get; set; } 
     int maritalStatusId { get; set; } 
} 

public class Address 
{ 
     public long addressId{ get; set; } 
     long customerId{ get; set; } 
     short addressTypeId{ get; set; } 
     string postCode{ get; set; } 
     string geoCodeLattitude{ get; set; } 
     string geoCodeLongitude{ get; set; } 
} 

public class Account 
{ 
    long accountID{ get; set; } 
     string accountDesc{ get; set; } 
     short accountStatusID{ get; set; } 
     DateTime joinDate{ get; set; } 
     DateTime insertDateTime{ get; set; } 
} 

나는 결과 세트가 될 아래와 같이 보일 것입니다 새 CustomerProfile의 목록을 반환 할 때.

List<object>을 사용하여 모두 저장하거나 고객/주소/계정을 캡슐화하는 CustomerProfile 클래스를 만들어야합니다.

public class CustomerProfile 
{ 
public Customer { get; set;} 
public Address { get; set;} 
public Account { get; set:} 
} 

그럼 당신은 당신이 고객, 주소 및 계정 말했듯이 세 가지 엔티티가

List<CustomerProfile>

+0

수퍼 클래스를 제공해 주시겠습니까? – user995099

+0

위와 비슷한 것 – ChrisBint

+0

수퍼 클래스가 없습니다.이 경우 구성은 친구입니다. – Enigmativity

0

수 있습니다. 귀하의 두 entite 고객과 주소가 협회 있지만 계정이 어떤 연관이 없다, 그것은 그것이 그 Entity 말 목록에있는 Account 테이블의 모든 Account 데이터를 보유 할 수 있음을 의미합니다.

먼저 주소를 보유하는 고객 클래스의 목록으로 속성을 만들 수 있습니다. 두 번째로 다른 속성을 계정 목록으로 정의 할 수 있습니다.

응용 프로그램을로드하면 모든 고객과 해당 주소를 가져 와서 Cusotmer 개체와 해당 Address 속성 및 Account를 채울 수 있습니다.

이제 고객의 개체를 가져 오면 주소와 계정의 두 속성을 통해 쉽게 데이터에 액세스 할 수 있습니다.

또한 모든 엔티티를 목록으로 정의 할 수있는 CustomerProfile 클래스를 만들 수 있습니다. 그러면 응용 프로그램을 실행할 때 모든 속성을 채워 고객 프로필의 개체에 액세스 할 수 있습니다.

관련 문제