Is it possible to order a System.Collection.IList without casting it to a known type?
I'm receiving a list as object
and casting it to a IList using
var listType = typeof(List<>);
var cListType = listType.MakeGenericType(source.GetType());
var p = (IList)Activator.CreateInstance(cListType);
var s = (IList)source;
and I want to order it based on Id which may or may not be available.
What I want to procude is something like:
if (s.First().GetType().GetProperties().where(m=>m.Name.Contians("Id")).FirstOrDefault != null)
{
s=s.OrderBy(m=>m.Id);
}
However, s does not have the extension method "Order" and neither have the extension method "First"