c# - Use SQL 2012 FORMAT function with LINQ to Entity Framework -


i add built in sql 2012 format function static function class use linq entity framework.
followed this source code mimic adding built in sql function.

public static class extendsqlfunctions {         [dbfunction("sqlserver", "format")]     public static string format(int64? arg, string formattype, string culture)     {         throw new notsupportedexception();     }     } 

error: specified method 'system.string format(system.nullable`1[system.int64], system.string, system.string)' on type 'extendsqlfunctions' cannot translated linq entities store expression.

update
able working version adding "format" ssdl of entity framework model.
looks microsoft not support "dbfunction sqlserver" outside of internal libraries.
not sure this?
http://msdn.microsoft.com/en-us/library/vstudio/bb738614(v=vs.100).aspx
if knows how add built in sql function without editing ssdl please let me know.


update
have added issue on codeplex
https://entityframework.codeplex.com/workitem/2586
, "rjperes" added discussion on codeplex.
https://entityframework.codeplex.com/discussions/572518

if using code first (not clear question), besides applying dbfunction attribute, need register function on model, in onmodelcreating method. name , namespace set in dbfunction attribute must match call edmfunction.create. see full example here: registering sql server built-in functions entity framework code first


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -