Linq access property by variable

You can write an extension method public static class MyExtensions { public static object GetProperty<T>(this T obj, string name) where T : class { Type t = typeof(T); return t.GetProperty(name).GetValue(obj, null); } } and use it like this var x = myList.Where(f => f.GetProperty(“Title”) == myValue);

C# FindAll VS Where Speed

The FindAll method of the List<T> class actually constructs a new list object, and adds results to it. The Where extension method for IEnumerable<T> will simply iterate over an existing list and yield an enumeration of the matching results without creating or adding anything (other than the enumerator itself.) Given a small set, the two … Read more