what are 'EdmFunctions' for?

≡放荡痞女 提交于 2019-12-20 06:29:55

问题


i saw the System.Data.Common.CommandTrees.ExpressionBuilder.EdmFunctions static class accidently, that contains a set of extension methods on System.Data.Common.CommandTrees.DbExpression, like AddDays, Concat,.... which bring back System.Data.Common.CommandTrees.DbFunctionExpression as return type, this static methods if needs to an argument, they only accept a System.Data.Common.CommandTrees.DbExpression type, in addition i look over the System.Data.Common.CommandTrees.DbExpression and i saw this class is abstract and by its static members you can create a System.Data.Common.CommandTrees.DbExpression, and send them to System.Data.Common.CommandTrees.ExpressionBuilder.EdmFunctions to use its extension methods,

my questions are:

  • what are these extensions for ?
  • how and where can we use this extension methods ?
  • have these extension methods mapped to canonical functions and are as helper method for using in Linq, like System.Data.Objects.EntityFunctions's methods or System.Data.Objects.SqlClient.SqlFunctions's Methods ?

whereas there is a attribute with name System.Data.Metadata.Edm.EdmFunction and by this, you can create CLR functions and map them to created model-defined functions for using in Linq,

  • is there a relation between these ?

could you attach any sample? or link to any documentaion?


回答1:


These methods are not meant for general consumption, you continue to use SqlFunctions or EntityFunctions in client code. They are the stock implementations of the canonical functions that can execute on an arbitrary provider. Microsoft includes the providers for XML, BCL collections and Entity SQL. Somebody else can create a provider to, say, their own dbase engine or ORM.

The mapping from, say, EntityFunctions.AddDays() to EdmFunctions.AddDays() occurs dynamically when the query comprehension is executed.



来源:https://stackoverflow.com/questions/21607456/what-are-edmfunctions-for

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!