2010-03-10 108 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. 
    } 
});