は、私は次の形式のコードの一部が見つかりました: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: "メソッド、デリゲートまたはイベントが期待されています" –