나는 다음과 같은 형태의 코드 조각을 발견 :Expression을 다른 메서드로 반환하는 메서드를 나타내는 구문은 무엇입니까?
public static Expression<Func<Invoice, CustomerContact>> GetCustomerContact()
{
return i => new CustomerContact {
FirstName = i.Customer.FirstName,
LastName = i.Customer.LastName,
Email = i.Customer.Email,
TelMobile = i.Customer.TelMobile,
};
}
코드의 다른 부분에서를, 나는 송장에서뿐만 아니라, 같은 경량 CustomerContact
개체를 얻을 싶어하지만 고객 자체에서. 할 수있는 분명한 것은이하는 것입니다 그래서 : 다음
public static Expression<Func<Customer, CustomerContact>> GetCustomerContact()
{
return c => new CustomerContact {
FirstName = c.FirstName,
LastName = c.LastName,
Email = c.Email,
TelMobile = c.TelMobile,
};
}
을하고 Expression
이 방법, 즉 참조 입력으로 Invoice
을 복용 변경이 같은 :
public static Expression<Func<Invoice, CustomerContact>> GetCustomerContact()
{
return i => GetCustomerContact(i.Customer); // doesn't compile
}
에 대한 올바른 구문 무엇 이?
오류를 게시하면 도움이됩니다. –
@newStackExchangeInstance : "메서드, 대리자 또는 이벤트가 필요합니다." –