Skip to content
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

KA-389 Add a GetCodename method to ICodeFirstTypeProvider #121

Merged

Conversation

Neytus
Copy link

@Neytus Neytus commented Aug 23, 2018

The PR fixes this issue.
A GetCodename method signature is introduced to the ICodeFirstTypeProvider interface.

Internal ref: KA-389

@Neytus Neytus force-pushed the feature/KA-389_Bi-directional_resolving_for_type/codename branch from b8074f8 to 6cb2f0d Compare August 23, 2018 10:55
@petrsvihlik petrsvihlik self-requested a review August 23, 2018 12:19
}

return TypesDictionary.Keys.First(type => GetCodename(type).Equals(contentType));
Copy link
Contributor

Choose a reason for hiding this comment

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

wouldn't FirstOrDefault do the trick?

/// Returns a codename corresponding to the given content type model.
/// </summary>
/// <param name="contentType">Content type model.</param>
string GetCodename(Type contentType);
Copy link
Contributor

Choose a reason for hiding this comment

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

now you can rewrite or maybe even get rid of the ContentTypeExtractor class

Copy link
Contributor

Choose a reason for hiding this comment

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

but make sure you keep the tests that check whether the system.type query param is added

@petrsvihlik petrsvihlik added this to the 6.0.0 milestone Aug 23, 2018
@Neytus Neytus force-pushed the feature/KA-389_Bi-directional_resolving_for_type/codename branch 2 times, most recently from c04db7f to 593c875 Compare August 31, 2018 15:06
@Neytus Neytus force-pushed the feature/KA-389_Bi-directional_resolving_for_type/codename branch from 593c875 to b3c74a0 Compare September 4, 2018 10:44

var codename = _codeFirstModelProvider.TypeProvider.GetCodename(typeof(T));

if (!IsAlreadyInParameters(parameters) && codename != null)
Copy link

Choose a reason for hiding this comment

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

Performance hint: Switch the check, if codename is null there is no need to check the params.

return enhancedParameters;
}

private static bool IsAlreadyInParameters(IEnumerable<IQueryParameter> parameters)
Copy link

Choose a reason for hiding this comment

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

What is in the parameters? Please provide better name, something like IsTypeInParameters().

@Neytus Neytus force-pushed the feature/KA-389_Bi-directional_resolving_for_type/codename branch from b3c74a0 to 8bbb760 Compare September 4, 2018 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants