WCF RIA服务定制方法?

Jok*_*ker 2 silverlight wcf ria

WCF RIA服务是否支持自定义方法?还能在哪个dll中找到"[Custom]"属性?

Rus*_*Rus 7

是的WCF RIA服务可以支持自定义方法.

您可以使用[Invoke]属性指定装饰自定义方法.例如:

[EnableClientAccess()]
public class TestDomainService : LinqToEntitiesDomainService<TestEntities>
{
  [Invoke]
  public Test CustomMethodFetch(Guid testId)
  {
    ...
    return foundTest; 
  }
}
Run Code Online (Sandbox Code Playgroud)

..你会用它来称呼它...

var ctx = new TestDomainContext();

ctx.CustomMethodFetch( testId, (op) =>
{
  if (op.HasError)
    // Handle errors.
  else
  {
    var testEntity = op.Value;
    // Do stuff.
  }
});
Run Code Online (Sandbox Code Playgroud)