Skip to content

SelectMany() not fond #158

Open
Open
@cuiliang

Description

@cuiliang

code:

var dictList = new List<Dictionary<string, string>>
{
    new Dictionary<string, string>()
    {
        {"key1", "value1"},
        {"key2", "value2"}
    },
    new Dictionary<string, string>()
    {
        {"key3", "value3"},
        {"key4", "value4"}
    }
};


var mergedDict = dictList
	.SelectMany(d => d)
	.ToDictionary(kv => kv.Key, kv => kv.Value);

error:
Oops! No applicable member has been found for the expression. The error occurred for expression "." at position 315 near ".SelectMany(d => d)

Full source code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Z.Expressions;

namespace ConsoleApp7
{
    internal class Program
    {
        static void Main(string[] args)
        {
            string code = """
                          var dictList = new List<Dictionary<string, string>>
                          {
                              new Dictionary<string, string>()
                              {
                                  {"key1", "value1"},
                                  {"key2", "value2"}
                              },
                              new Dictionary<string, string>()
                              {
                                  {"key3", "value3"},
                                  {"key4", "value4"}
                              }
                          };


                          var mergedDict = dictList
                          	.SelectMany(d => d)
                          	.ToDictionary(kv => kv.Key, kv => kv.Value);
                          """;

            try
            {
                Eval.Execute(code);

            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
            }
            Console.ReadLine();
        }
    }
}

Metadata

Metadata

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