-
Notifications
You must be signed in to change notification settings - Fork 473
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
MissingMethodException on getting ResourceInstance from ODataResourceSerializer #2558
base: master
Are you sure you want to change the base?
Conversation
I couldn't solve the tests. I think someone needs to take a look.
Send query https://localhost:5001/oData/Student?$select=Id,FirstName It will throw exception from DeserializationHelpers.SetProperty(resource, propertyName, value); 261 line ResourceContext.cs @xuzhg I think these changes were made by you. |
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.
It seems this PR is addressing a specific use case for you.
In the next release of WebApi Aspnetcore v8.x, we will have the ability to inject a custom implementation of the SelectExpandBinder
(PR). That should work for you.
Maybe, but I am using v7.x. Is it possible to merge that branch in version 7.x also? |
@xuzhg @gathogojr What do you think? |
I am seeing Activator.CreateInstanse on BuildResource method on v.8x also. I think the problem exists on v.8x also |
@@ -293,9 +293,10 @@ internal Expression ProjectElement(Expression source, SelectExpandClause selectE | |||
LinqParameterContainer.Parameterize(typeof(string), _modelID) : | |||
Expression.Constant(_modelID); | |||
wrapperTypeMemberAssignments.Add(Expression.Bind(wrapperProperty, wrapperPropertyValueExpression)); | |||
|
|||
bool instanseOfWrapperClassWasSet = false; |
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.
super nit: spelling "instance"
@@ -109,10 +109,12 @@ public void Bind_GeneratedExpression_ContainsExpandedObject() | |||
|
|||
// Assert | |||
IEnumerator enumerator = queryable.GetEnumerator(); | |||
IEnumerator _querableEnumerator = _queryable.GetEnumerator(); |
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.
IEnumerator
implements IDisposable
. Please wrap this in a using
block
return Expression.MemberInit(Expression.New(wrapperType), wrapperTypeMemberAssignments); | ||
|
||
if (instanseOfWrapperClassWasSet) | ||
return Expression.MemberInit(Expression.New(wrapperType), wrapperTypeMemberAssignments); |
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.
as per code guidelines, please enclose body of conditional in braces (even if it's a single line). Improves code readability and reduces introducing logical errors later.
This PR has Quantification details
Why proper sizing of changes matters
Optimal pull request sizes drive a better predictable PR flow as they strike a
What can I do to optimize my changes
How to interpret the change counts in git diff output
Was this comment helpful? 👍 :ok_hand: :thumbsdown: (Email) |
@komdil Can you please look at the review comments., thanks |
@Sreejithpin The tests are failing. It looks this solution will not work for solving this problem. I don't have next steps |
@komdil, I'd like to help out and take a look, but it seems that I can't kick off a new build. Do you mind re-running the checks? |
@komdil
$it => new SelectSome`1()
{
ModelID = value(Microsoft.AspNet.OData.Query.Expressions.LinqParameterContainer+TypedLinqParameterContainer`1[System.String]).TypedProperty,
Container = new NamedPropertyWithNext0`1()
{
Name = "Title",
Value = $it.Title,
Next0 = new AutoSelectedNamedProperty`1()
{
Name = "Id",
Value = Convert($it.Id, Nullable`1)
}
}
}
$it => new SelectAll`1() {
ModelID = value(Microsoft.AspNet.OData.Query.Expressions.LinqParameterContainer+TypedLinqParameterContainer`1[System.String]).TypedProperty,
Instance = $it,
UseInstanceForProperties = True
}
}
$it => new SelectAllAndExpand`1()
{
ModelID = value(Microsoft.AspNet.OData.Query.Expressions.LinqParameterContainer+TypedLinqParameterContainer`1[System.String]).TypedProperty,
Instance = $it,
UseInstanceForProperties = True,
Container = new NamedProperty`1()
{
Name = "Authors",
Value = $it.Authors.Select($it => new SelectAll`1()
{
ModelID = value(Microsoft.AspNet.OData.Query.Expressions.LinqParameterContainer+TypedLinqParameterContainer`1[System.String]).TypedProperty,
Instance = $it,
UseInstanceForProperties = True
}
)
}
} We don't set the Your PR introduces an Instance property in all scenarios. |
Issues
This pull request fixes issue #2557.
Description
Adding constructor param on generic SelectExpandWrapper class for setting instance of resource
Checklist (Uncheck if it is not completed)
Additional work necessary
If documentation update is needed, please add "Docs Needed" label to the issue and provide details about the required document change in the issue.