2011-09-23 8 views
0

메소드의 리턴을 클래스 속성에 공개 할 수 있습니까?메소드로 메소드 반환하기

public class BIContactLib: ContactLib 
{ 

    //Expose it here.. to replace the code below 

    public IEnumerable<BIContactLib> GetContactLibs 
    { 
     get { return (BIContactLib) GetAll} 
     set { ; } 
    } 
} 

public class BIContactLibService : IBIRequirement, IDisposable 
{ 
    private ClientContext context = new ClientContext(); 

    //The return of the method here is the one I would like to expose 

    public IEnumerable<BIContactLib> GetAll() 
    { 
     var contactslib = context.ContactLibs; 
     return contactslib.ToList(); 
    } 
} 

이 뒤에 그 이유는 내가 ... 연락처 라이브러리의 목록을 가지고와 뷰 모델을 만들 것입니다을 heres 내보기 그런데 모델 ..

public class PersonInformation 
{ 
    public BIPerson Person { get; set; } 
    public BIAddress Address { get; set; } 

    //This is where i want to use it 

    public IEnumerable<BIContactLib> GetAll { get; set; } 
} 

또는 다른 방법 이것을하기 위해?

안부,

답변

1

방법이

public IEnumerable<BIContactLib> GetContactLibs 
    { 
     get { 
      BiContractLib lib = new BiContractLib(); 
      return lib.GetAll(); 
      }   
    } 
같은 약