Skip to content

是否可以考虑增加对 string.Join() 方法的支持 #405

Closed
@hd2y

Description

@hd2y

代码:

var list = freeSql.Queryable<Music>()
    .ToList((a) => new
    {
        a.Id,
        a.Name,
        Tags = string.Join(",", freeSql.Select<Tag>().Where(b => a.Id == b.MusicId).ToList(b => b.Name))
    });

public class Music
{
    [Column(IsIdentity = true)]
    public int Id { get; set; }

    public string Name { get; set; }
}

public class Tag
{
    [Column(IsIdentity = true)]
    public int Id { get; set; }

    public int MusicId { get; set; }

    public string Name { get; set; }
}

SQL 脚本:

-- SQLite
SELECT a.Id, a.Name, (SELECT GROUP_CONCAT(b.Name) FROM Tag b where a.Id = b.MusicId) FROM Music a;

其他数据库的实现:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions