This project is read-only.
2

Closed

Enable collections of primitive types as input parameters

description

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<string> collection, string separator = ", ")
{}

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.
Closed Nov 19, 2016 at 9:02 PM by moozzyk

comments