List<T> objectList = GetList();
foreach (T setName in setNames)
{
List<T> list = objectList.Where(x => x.QualificationID == setName).ToList();
redisClient.SetAdd<string>("Qualification:" + setName, list.Select(x => x.ProductID).ToString());
}
In Line 3, T does not contain a definition for 'QualificationID' and no extension method 'QualificationID' accepting a first argument of Type T could be found.
Similarly in Line 4, T does not contain a definition for 'ProductID' and no extension method 'ProductID' accepting a first argument of Type T could be found.
how can we filter the list of generic object using linq?
EDIT : It is found not possible to filter the property value in a generic method until we specify the classtype. like extending method to,
method() where T : ClassType
as specified in the answers and comment.
where T : SomeTypegeneric type restraint in your method/class declaration.list.Select(x => x.ProductID).ToString()will yield nothing usefull, as.Select()returns anIEnumerable<T>, who's .ToString()method returns the type name.