private void FillProperty(object viewModel, PropertyInfo property) { object result = null; var propertyType = property.PropertyType; var baseType = propertyType.GetGenericTypeDefinition(); var innerType = propertyType.GetGenericArguments()[0]; var data = GetQueryableDataFor(innerType); var filters = FilterLocator.GetFiltersByConvention(innerType, property); foreach(var filter in filters) { data = new FilterExecutor().Execute(filter, data); } if (baseType == typeof(IPagedList<>)) { // ToDo Um how do we page a filled property? probably a bad idea result = Utilities.ToPagedList(innerType, data,new PagingCriteria()); } else if (baseType == typeof(IEnumerable<>) || baseType == typeof(IList<>)) { result = Utilities.ToList(innerType, data); } else if(baseType == typeof(IQueryable<>)) { result = data; } property.SetValue(viewModel, result, null); }
private void FillProperty(object viewModel, PropertyInfo property) { object result = null; var propertyType = property.PropertyType; var baseType = propertyType.GetGenericTypeDefinition(); var innerType = propertyType.GetGenericArguments()[0]; var data = GetQueryableDataFor(innerType); var filters = FilterLocator.GetFiltersByConvention(innerType, property); foreach (var filter in filters) { data = new FilterExecutor().Execute(filter, data); } if (baseType == typeof(IPagedList <>)) { // ToDo Um how do we page a filled property? probably a bad idea result = Utilities.ToPagedList(innerType, data, new PagingCriteria()); } else if (baseType == typeof(IEnumerable <>) || baseType == typeof(IList <>)) { result = Utilities.ToList(innerType, data); } else if (baseType == typeof(IQueryable <>)) { result = data; } property.SetValue(viewModel, result, null); }