score:1
functions declared in the database provider are normally available under the provider's namespace. so if this was a normal entity sql query you should be able to invoke stuff() adding sqlserver before it, e.g. sqlserver.stuff(strtime, 3, 0, ':').
however, the entity sql in the body of a model-defined functions can only refer to other canonical functions or other model-defined functions, i.e. model-defined functions cannot be made provider specific by referring to provider specific functions.
this is a limitation that was adopted by choice. when your application executes a linq query you can execute provider specific functions because your application already depends on a full model with conceptual and store schemas and a mapping specification. model-defined functions on the other hand are part of the conceptual model, which is supposed to be self-contained: you should be able swap the provider, store schema or mapping specification for different ones without ever rendering the conceptual model invalid. hence things that are defined in the conceptual model cannot depend on things that are defined elsewhere.
workaround:
i did some experimentation and came up with this naïve way to simulate sql server's stuff() using only canonical functions that should work across providers. you can use something like this from your own model-defined function by specifying the namespace of the conceptual model, e.g. 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>
Source: stackoverflow.com
Related Query
- How to get Entity Framework 6 to use SQL STUFF function inside CSDL?
- Does Linq in Entity Framework code first use SQL or does it get the whole table first?
- Use SQL 2012 FORMAT function with LINQ to Entity Framework
- how to use T-SQL Max inside of linq query in entity framework 6
- How get Row Index in a SQL Database using entity framework without query all data?
- How to use Where condition inside Include in entity framework LINQ?
- How do use LINQ with Entity framework to get a count of records on max of a joined column
- How to call an Sql User defined Function using Entity frame work Code first approach with LInq c#
- How to use one Column of Sql query into another sql query inside C# Code
- how to use entity framework to group by date not date with time
- Get All Except from SQL database using Entity Framework
- How can i write SQL update query with where clause in Entity Framework in C#
- How can I use Entity Framework on an object graph past a depth of 2 with MySQL Connector / NET?
- How to add SQL user-defined function to entity framework?
- how to get single value by using entity framework
- How to use a stored procedure in ADO.NET Entity Framework
- How to get the latest row in a table using Entity Framework (considering performance)?
- Entity Framework Core : how can I use DateDiff in Linq?
- How to get a distinct, case-insensitive list using Linq and Entity Framework
- How to use DbGeography.Filter in Linq with Entity Framework 5?
- How do LINQ queries against the Entity Framework communicate dates to a SQL Server?
- How to get Multiple Result Set in Entity Framework using Linq with C#?
- How to bind data from mutiple tables to datagridview using Entity Framework and use CRUD operations?
- How to get SQL query into LINQ form in C# code
- How to optimize SQL query generated by Entity Framework in SQL Server Management Studio?
- How to apply the SQL in keyword in Entity Framework method syntax?
- How to get max value of a string column of numbers in Entity Framework
- How to Create a Run-Time Computed (NotMapped) Value in Entity Framework Code First
- Use Entity Framework Select Single Row. Entity Framework did not generate sql statement right?
- How to get a count of records with entity framework and repository pattern
More Query from same tag
- Trying to Filter a collection using LINQ where the collection has a collection which also has a collection with a property that is nullable
- Use Linq to flatten a nested list instead of a foreach loop
- Return concatenated set of member IEnumerables from List of objects
- Exclude linq join condition based on parameter
- Left join with linq
- Expression.Invoke in Entity Framework?
- LINQ - SelectMany with Strongly-typed DataSets
- How do you handle arbitrary namespaces when querying over Linq to XML?
- Uncheck all CheckBoxes using Linq
- C#, LInq, Entity Framework 4: Split a table in to a two dimensional array using Linq
- How can apply a group by to a result of another group by using MongoDb?
- Dynamic LINQ query string for indexing into IEnumerableObjects for efficient Multidimensional Array sorting
- Select numerical order in linQ
- LINQ get 10 objects based on integer in object row
- Compare dd-mm-yyyy datetime
- C# Linq where list in list
- Workaround for MethodBase.GetCurrentMethod() on Compact Framework 3.5
- Defining a one-to-one relationship in SQL Server
- Invoking Generic Method with the parameter of IEnumerable<T>
- Filtering IQueryable using self defined function causes runtime error
- Does Enumerable.Repeat() do a deep copy?
- How to make a collection be "n" elements long using extension methods?
- Filter on nested object in LINQ
- Adding Expression argument as property in LINQ to Entities
- VB.NET LINQ how to concatenate a Select
- Is it better to store query results in memory, or run the same query multiple times?
- How to get a running total of a decimal in a query?
- Determine table during runtime with Linq
- Include statement return empty list/null Linq
- How to generate array of objects after LINQ to xml in C#