LINQ to Entities split string on result

前端 未结 1 1113
情歌与酒
情歌与酒 2021-01-12 11:44

I have a LINQ statement as follows:

var playedBanDataList =
    from bannedPlayers in query
    select new PlayerBanData
    {
        Admin = bannedPlayers.         


        
1条回答
  •  借酒劲吻你
    2021-01-12 12:15

    You can use AsEnumerable to make the select occur in memory instead of EF.

    var playedBanDataList = query.AsEnumerable()
        .Select(bannedPlayers => new PlayerBanData
        {
            Admin = bannedPlayers.Admin,
            BannedUntil = bannedPlayers.BannedUntil,
            IsPermanentBan = bannedPlayers.IsPermanentBan,
            PlayerName = bannedPlayers.PlayerName,
            Reason = bannedPlayers.Reason,
            IpAddresses = bannedPlayers.IpAddresses.Split(
                new [] {","}, 
                StringSplitOptions.RemoveEmptyEntries).ToList()
        });
    

    0 讨论(0)
提交回复
热议问题