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

NHibernate.Linq not support string.join with group, throw "The method or operation is not implemented." #3293

Open
superboy1984 opened this issue Apr 25, 2023 · 1 comment

Comments

@superboy1984
Copy link

superboy1984 commented Apr 25, 2023

The sql statement I want to implement is
select log.OPUserId as PutStaffId,max(log.OPUserName) as PutStaffName,**group_concat(log.Id)** as PutLogIdsStr,sum(log.Point) as Point from PromotionAccountPutLog log where .. group by log.OPUserId

var statisticsList = (from log in session.Query<PromotionAccountPutLog>().Where(w => ...)
                           group log by log.OPUserId into g
                           select new PutStaffCommissionStatisticsDto
                           {
                               PutLogIdsStr = string.Join(',', g.Select(s => s.Id)), 
                               //PutLogIdsStr = g.GroupConcat(x => x.Id),
                               PutStaffId = g.Key,
                               PutStaffName = g.Max(x => x.OPUserName),
                               Point = g.Sum(s => s.Point),
                               ...
                         }).ToList();

then i try [LinqExtensionMethod("group_concat")], but throw "must be reducible node"

public static class CustomLinqExtensions
    {
        [LinqExtensionMethod("group_concat")]
        public static string GroupConcat<TSource, TResult>(this IEnumerable<TSource> source, Func<TSource, TResult> selector)
        {
            throw new NotImplementedException();
        }
    }

nhiberante 5.4.2, mysql 8.0.31

@superboy1984
Copy link
Author

superboy1984 commented Apr 29, 2023

efcore supports string.join from version 7.0,and MySql.EntityFrameworkCore 7.0.0 can transate string.Join(',', g.Select(s => s.Id)) with mysql funcation group_concat.
bellow Function Mappings of the Microsoft SQL Server Provider:
https://learn.microsoft.com/en-us/ef/core/providers/sql-server/functions

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