Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable collections of primitive types as input parameters #4

Open
moozzyk opened this issue Nov 19, 2016 · 0 comments
Open

Enable collections of primitive types as input parameters #4

moozzyk opened this issue Nov 19, 2016 · 0 comments

Comments

@moozzyk
Copy link
Owner

moozzyk commented Nov 19, 2016

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 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant