-
Notifications
You must be signed in to change notification settings - Fork 58
Default expansion of dictionaries supported #240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I did some testing, and it seems to also work with a complex type as TValue. |
Don't we want to just support dictionaries as lists? For example just replace the call to public static Type GetUnderlyingElementType(this Type type)
{
TypeInfo tInfo = type.GetTypeInfo();
if (tInfo.IsArray)
return tInfo.GetElementType();
if (!type.IsGenericType)
throw new ArgumentException(nameof(type));
Type[] genericArguments = type.GetGenericArguments();
Type genericTypeDefinition = type.GetGenericTypeDefinition();
if (genericTypeDefinition == typeof(IGrouping<,>))
return genericArguments[1];
else if (typeof(IDictionary<,>).IsAssignableFrom(genericTypeDefinition))
return typeof(KeyValuePair<,>).MakeGenericType(genericArguments[0], genericArguments[1]);
else if (genericArguments.Length == 1)
return genericArguments[0];
else
throw new ArgumentException(nameof(type));
} |
Probably best to include a test with a key or value complex type if that's possible - agree? |
Add an implementation of GetUnderlyingElementType inside AutoMapper.AspNet.OData instead of using the one from LogicBuilder.Expressions.Utils.
Yeah I agree. I added GetUnderlyingElementType method in TypeExtensions. |
I will add a test. Side note: It made me realize that it would be useful to have an easier way of running Web.Tests. We would be able to test if the serialization of dictionaries is working. Maybe in another PR. |
ready for review. |
….TypeExtensions.GetUnderlyingElementType in LinqExtensions.
Thanks. |
On the build server? Nice if you can make it work. I've always used IIS hosts so didn't consider it honestly. |
Hi @BlaiseD,
Related to #239.
I think I added what was missing to support default expansion of dictionaries.
I was wondering if I would need to do do some code to select child properties of the dictionary values when TValue is an object with properties. i.e. `Dictionary<string, MyObj> and MyObj is a complex type.