How to force Entity Framework 6 to use SQL STUFF function inside CSDL?

I am using EF 6.1 and would like to create a custom function in the CSDL section of the EDMX file, which can call the STUFF function built into SQL 2012.
It's very simple for me. (NOTE: This assumes HHMM time without a colon)

<Function Name="StringToDate" ReturnType="DateTime">
    <Parameter Name="strDate" Type="String" />
    <Parameter Name="strTime" Type="String" />
    <DefiningExpression>
        CAST(CASE WHEN strDate &lt;&gt; '' THEN strDate + ' ' 
            + STUFF(strTime, 3, 0, ':') END AS DateTime)
    </DefiningExpression>
</Function>

The above code works if I delete the "STUFF" command, but with the "STUFF" command that I get, "STUFF" cannot be resolved to a valid type or function. "

I can use "Entity.SqlServer.SqlFunctions.Stuff" in LINQ to Entity just fine, but not in CSDL.

NOTE. I use the STUFF command to insert a Colon between the 2nd and 3rd characters in a time variable.

: " "
, , STUFF CSDL, .

CAST(CASE WHEN strDate &lt;&gt; '' THEN strDate + ' ' +  SUBSTRING(strTime, 1, 2) + ':' + SUBSTRING(strTime, 3, 2) END AS DateTime)



: . , , . https://entityframework.codeplex.com/workitem/2583

+4
1

, , . , SQL- Entity, STUFF(), SqlServer , . SqlServer.STUFF(strTime, 3, 0, ':').

, Entity SQL , , .

, . LINQ, , . , , , : , , . , , , , .

:

SQL Server Stuff(), , . - , , . Model1.Stuff(strTime, 3, 0, ':')

<Function Name="Stuff" ReturnType="String">
  <Parameter Name="character_expression" Type="String" />
  <Parameter Name="start" Type="Int32" />
  <Parameter Name="length" Type="Int32" />
  <Parameter Name="replaceWith_expression" Type="String" />
  <DefiningExpression>
    Left(character_expression,start-1) 
    + replaceWith_expression 
    + Substring(character_expression, start + length, Length(character_expression))
  </DefiningExpression>
</Function>
+1

All Articles