-
Notifications
You must be signed in to change notification settings - Fork 41
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
KA-389 Add a GetCodename method to ICodeFirstTypeProvider #121
Conversation
b8074f8
to
6cb2f0d
Compare
} | ||
|
||
return TypesDictionary.Keys.First(type => GetCodename(type).Equals(contentType)); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
c04db7f
to
593c875
Compare
593c875
to
b3c74a0
Compare
|
||
var codename = _codeFirstModelProvider.TypeProvider.GetCodename(typeof(T)); | ||
|
||
if (!IsAlreadyInParameters(parameters) && codename != null) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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().
b3c74a0
to
8bbb760
Compare
The PR fixes this issue.
A
GetCodename
method signature is introduced to theICodeFirstTypeProvider
interface.Internal ref: KA-389