Last post Mar 30, 2015 03:24 AM by Kevin Shen - MSFT
Mar 17, 2015 02:03 PM|remojr76|LINK
I have a generic repository method that I want to include child collections with, I am stuck on how to compose the Linq this is what I have so far:
public List<T> Get(bool childCollections = true)
PropertyInfo props = typeof(T).GetType().GetProperties();
List<PropertyInfo> properties = new List<PropertyInfo>();
foreach(var p in props)
if(p.GetType() == typeof(IEnumerable<>))
Mar 18, 2015 10:21 AM|itpreneur|LINK
I am confused on what you have described. What do you mean by childcollection of what? Are you talking about child collection of related entities? It doesn't ring a bell.
Mar 30, 2015 03:24 AM|Kevin Shen - MSFT|LINK
In your code ,you could first get the child collection .then loop the child collection.
create a new list to store the entity in your child collection.
then loop the properties in your entity just like what you have done.