using System.Collections.Generic;
using System.Linq.Expressions;
public static void Main(string[] args)
var www = "substringof('',bushCode) | fieldName";
Console.WriteLine(www.Split('|')[1]);
var students = new List<Student>
new Student { StudentID = 1, StudentCode = "10", Age = 21 },
new Student { StudentID = 2, StudentCode = "10", Age = 22 },
new Student { StudentID = 3, StudentCode = "101", Age = 23 },
new Student { StudentID = 4, StudentCode = "103", Age = 24 },
new Student { StudentID = 5, StudentCode = "109", Age = 24 },
var r = students.Where(Like<Student>("StudentCode", "10").Compile());
Console.WriteLine(e.Age);
static Expression<Func<TEntity, bool>> Like<TEntity>(string propertyName, string queryText)
var parameter = Expression.Parameter(typeof (TEntity), "entity");
var getter = Expression.Property(parameter, propertyName);
if (getter.Type != typeof (string))
throw new ArgumentException("Property must be a string");
var stringContainsMethod = typeof (string).GetMethod("Contains", new[] {typeof (string)});
var containsCall = Expression.Call(getter, stringContainsMethod,
Expression.Constant(queryText, typeof (string)));
return Expression.Lambda<Func<TEntity, bool>>(containsCall, parameter);
public int StudentID { get; set; }
public string StudentCode { get; set; }
public int Age { get; set; }