OData 元数据中 <FunctionImport> 的含义是什么?

What is meaning of <FunctionImport> in OData Metadata?

看了OData doc之后,还是不明白<FunctionImport>的意思。

  1. 那是做什么用的? 有人说 "Function imports are used to perform custom operations on a JPA entity in addition to CRUD operations. For example, consider a scenario where you would like to check the availability of an item to promise on the sales order line items. ATP check is a custom operation that can be exposed as a function import in the schema of OData service."

不过我觉得一般<Function>也能达到上面的要求吧?

  1. <FunctionImport><Function> 到底有什么区别?

非常感谢任何人的帮助! 谢谢

好的,我自己得到了答案。 <OData Version 4.0 Part 1: Protocol Plus Errata 02>: 操作允许在部分数据模型上执行自定义逻辑。函数是没有副作用的操作,可以支持进一步的组合,例如,使用额外的过滤操作、函数或动作。动作是允许副作用的操作,例如数据修改,并且不能进一步组合以避免非确定性行为。动作和函数或者绑定到一个类型,使它们能够作为该类型实例的成员被调用,或者未绑定,在这种情况下它们被称为静态操作。动作导入和函数导入允许从服务根调用未绑定的动作和函数。

OData中有三种类型的函数:

  1. 绑定到某物(例如实体)的函数。例子是 GET http://host/service/Products(1)/Namespace.GetCategories() 此类函数使用 <function> 元素在元数据中定义,其 isBound 属性设置为 true.
  2. 未绑定函数。它们通常用于查询。例如。 GET http://host/service/Products?$filter(Name eq Namespace.GetTheLongestProductName()) 此类函数在元数据中使用 <function> 元素定义,其 isBound 属性设置为 false
  3. 函数导入。它们是可以在服务根调用的函数。例如。 GET http://host/service/GetMostExpensiveProduct() 它们的概念有点类似于程序语言中的静态函数的概念,它们使用 <functionimport> 元素在元数据中定义。

<action><actionimport>也有类似的区别。