Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

Preserve ViewDataDictionary.ModelType for Nullable<T> properties when Model is non-null #2988

Closed
wants to merge 1 commit into from

Conversation

dougbu
Copy link
Member

@dougbu dougbu commented Aug 18, 2015

…when `Model` is non-`null`

- #2539
- reuse `ModelMetadata` and occasionally `ModelExplorer` when `ModelType` is `Nullable<T>`
@dougbu
Copy link
Member Author

dougbu commented Aug 18, 2015

/cc @rynowak @pranavkm

@@ -186,7 +186,9 @@ protected ViewDataDictionary([NotNull] ViewDataDictionary source, object model,
{
// This is the core constructor called when Model is known.
var modelType = GetModelType(model);
if (modelType == source.ModelMetadata.ModelType && model == source.ModelExplorer.Model)
var metadataModelType =
Nullable.GetUnderlyingType(source.ModelMetadata.ModelType) ?? source.ModelMetadata.ModelType;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we hoist this to a property on ModelMetadata?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea but suggest doing this (and a bit more) as a follow-up. Filed #2992

@rynowak
Copy link
Member

rynowak commented Aug 18, 2015

:shipit:

@dougbu
Copy link
Member Author

dougbu commented Aug 18, 2015

f10a071

@dougbu dougbu closed this Aug 18, 2015
@dougbu dougbu deleted the dougbu/nullable.viewdata.2539 branch August 18, 2015 17:50
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants