CodeFirstFunctions
CodeFirstFunctions copied to clipboard
Enable collections of primitive types as input parameters
Ported from: https://codefirstfunctions.codeplex.com/workitem/8
REPORTED ON: REPORTED BY: Nov 5, 2014 at 8:02 AM moozzyk
As per the comment to http://blog.3d-logic.com/2014/10/18/the-final-version-of-the-store-functions-for-entityframework-6-1-1-code-first-convention-released/ :
Is it also possible to support IEnumerable as an input parameter where T is a primitive type?
For example I am trying to implement the “GROUP_CONCAT” function for MSSQL (To simulate the functionality of GROUP_CONCAT in MYSQL) as a custom stored procedure. (See: http://goo.gl/UEDel4)
I have the stored procedure up and running but I cannot call it via a DbFunction because IEnumreable is currently not supported as a paramter.
The signature for this method would look look like this:
[DbFunction("MyContext", "GROUP_CONCAT")]
public static string GroupConcat(IEnumerable
An the usage scenario would be this.
from blog context.Set() select new BlogDto { Name = blog.Title, Tags = CustomDbFunctions.GroupConcat(blog .Tags.Select(x => x.Name)) }
This should return the following:
Name, | Tags My first blog, | Csharp, Linq, Ef My second blog | PHP, Ruby
This would basically be the same like DBFunctions.StandardDeviation(IEnumerable ..) where I also have a sequence of inputs and the functions returns an aggregated value.