105
private static UnaryExpression GetValueExpression(string propertyName, string val, ParameterExpression param)
1
using System;
2
using System.Collections.Generic;
3
using System.ComponentModel;
4
using System.Linq;
5
using System.Linq.Expressions;
6
using System.Reflection;
7
8
public class ConsoleAppForLambdas
9
{
10
private static readonly List<User> userData = UserDataSeed();
11
12
public static void Main(string[] args)
13
{
14
Console.WriteLine("Specify the property to filter");
15
string propertyName = Console.ReadLine();
16
Console.WriteLine("Value to search against: " + propertyName);
17
string value = Console.ReadLine();
18
19
//1: With Func delegate
20
//var dynamicExpression = GetDynamicQueryWithFunc(propertyName, value);
21
//var output = userData.Where(dynamicExpression).ToList();
22
23
//2: With Expression trees that generate Func and handles dynamic types with TypeDescriptor
24
var dn = GetDynamicQueryWithExpresionTrees(propertyName, value);
Cached Result