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

Implement count in expansion options #197

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

lenardchristopher
Copy link

@lenardchristopher lenardchristopher commented Nov 25, 2023

Addresses #137

Note: First time touching the code of this repo. I don't see any contribution docs, so I'm not sure what is necessary.

The test I wrote fails with the following exception

Expression of type 'System.Int32' cannot be used for parameter of type 'System.Collections.Generic.IEnumerable`1[AutoMapper.OData.EFCore.Tests.Model.ProductModel]' of method 'System.Collections.Generic.List`1[AutoMapper.OData.EFCore.Tests.Model.ProductModel] ToList[ProductModel](System.Collections.Generic.IEnumerable`1[AutoMapper.OData.EFCore.Tests.Model.ProductModel])' (Parameter 'arg0')
   at System.Dynamic.Utils.ExpressionUtils.ValidateOneArgument(MethodBase method, ExpressionType nodeKind, Expression arguments, ParameterInfo pi, String methodParamName, String argumentParamName, Int32 index)
   at System.Linq.Expressions.Expression.Call(MethodInfo method, Expression arg0)
   at AutoMapper.AspNet.OData.Visitors.MethodAppender.VisitMethodCall(MethodCallExpression node) in /Users/chrislenard/repos/AutoMapper.Extensions.OData/AutoMapper.AspNetCore.OData.EFCore/Visitors/MethodAppender.cs:line 43
   at AutoMapper.AspNet.OData.Visitors.MethodAppender.AppendQueryMethod(Expression expression, ODataExpansionOptions expansion, ODataQueryContext context) in /Users/chrislenard/repos/AutoMapper.Extensions.OData/AutoMapper.AspNetCore.OData.EFCore/Visitors/MethodAppender.cs:line 23

I interpret this to mean that COUNT was used properly, but handling the value in the result is throwing an error. Would love some advice. Thanks.

@lenardchristopher
Copy link
Author

@dotnet-policy-service agree

@BlaiseD
Copy link
Member

BlaiseD commented Nov 27, 2023

It's probably better to place the test here. The test should confirm that the count filed exists in the result. It should fail if run against the current code.

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.

2 participants