forked from zzzprojects/System.Linq.Dynamic.Core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRequest_Dictionary.cs
More file actions
26 lines (23 loc) · 995 Bytes
/
Request_Dictionary.cs
File metadata and controls
26 lines (23 loc) · 995 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
using System.Collections.Generic;
using System.Linq.Dynamic.Core;
using System.Linq.Dynamic.Core.CustomTypeProviders;
using System.Linq.Expressions;
namespace Z.Dynamic.Core.Lab
{
public class Request_Dictionary
{
public static void Execute()
{
object CreateDicParameter(string name) => new Dictionary<string, object>
{{"Name", new Dictionary<string, object> {{"FirstName", name }}}};
var config = new ParsingConfig()
{
CustomTypeProvider = new DefaultDynamicLinqCustomTypeProvider()
};
var parType = new Dictionary<string, object>().GetType();
var lambda = DynamicExpressionParser.ParseLambda(config, new[] { Expression.Parameter(parType, "item") }, typeof(object), "item.Name.FirstName").Compile();
var x1 = lambda.DynamicInvoke(CreateDicParameter("Julio"));
var x2 = lambda.DynamicInvoke(CreateDicParameter("John"));
}
}
}