2010-03-10 92 views

回答

7

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

您将指定使用[Invoke]属性修饰您的自定义方法。 EG:

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

..你会被称之为...

var ctx = new TestDomainContext(); 

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