【问题标题】:Untyped Custom Data Service Provider entity based service operation without using entity framework不使用实体框架的无类型自定义数据服务提供者基于实体的服务操作
【发布时间】:2014-02-14 10:46:36
【问题描述】:

我正在使用 C# 生成一个使用 OData 的无类型自定义数据服务提供程序
实现了所有必需的提供程序和接口。
所有实体将仅在元数据创建期间动态指定。
不能使用 EDMX 或反射提供程序。
提供所有访问权限。

1) 自定义元数据提供者

public bool TryResolveResourceType(string name, out ResourceType resourceType)  
{  
    return this.resourceTypes.TryGetValue(name, out resourceType);  
}
public bool TryResolveServiceOperation(string name, out ServiceOperation serviceOperation)  
{
    if (serviceOperations.TryGetValue(name, out serviceOperation))
    {
        serviceOperation.SetReadOnly();
        return true;
    }
    else
    {
        serviceOperation = null;
        return false;
    }            
}

2) 自定义数据查询提供者

public object InvokeServiceOperation(ServiceOperation serviceOperation, object[] parameters)
{
//Invoke the method present in ServiceOperation
}

当我给出以下网址时
http://localhost/SampleService.svc/TestEntity(1)/Id>
我能够获取 id 值。

当我使用 url 调用服务时
http://localhost/SampleService.svc/TestServiceOperation
我能够调用服务操作。

但是当我尝试调用 Serv.Op 时。指定实体后,我收到错误
http://localhost/SampleService.svc/TestEntity/TestServiceOperation

当我使用这个 url 时,它会找到对应的 TestEntityResourceSet,
然后去查找名称=TestServiceOperation 的资源类型。
但是 TestServiceOperation 没有资源类型。 需要在 TryResolveServiceOperation 中搜索到对应的 SO 名称。

所有在网上搜索的例子都像是调用了 Ser.Op。仅在 .svc/SO 类型之后。
我需要为每个实体单独调用服务操作。喜欢

http://localhostTest.svc/Entity1/SerOp1 http://localhostTest.svc/Entity2/SerOp2

有什么好的例子来说明如何做到这一点?谢谢。

【问题讨论】:

    标签: jquery asp.net odata wcf-data-services service-operations


    【解决方案1】:

    似乎您正在寻找绑定在 EntityType 上的操作。参见10.4.1。详情请在OData V3.0 Procotol 中操作

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多