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

Odata count inside Expand [.Net Core] #1564

Closed
albertoVieiraNeto opened this issue Aug 9, 2018 · 3 comments
Closed

Odata count inside Expand [.Net Core] #1564

albertoVieiraNeto opened this issue Aug 9, 2018 · 3 comments
Labels

Comments

@albertoVieiraNeto
Copy link

Short summary

Odata count function does not work properly when inside the expand property. either throws a exception or displays incorrect values.

Assemblies affected

Version affected/Tested :
Microsoft.AspNetCore.OData @7.0.1

Reproduce steps

Create 2 models

public abstract class ModelBaseWithId {
        [Required]
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int Id { get; set; }

        [Required]
        [DatabaseGenerated(DatabaseGeneratedOption.Computed)]
        public virtual Guid Guid { get; set; }

        [Required, DatabaseGenerated(DatabaseGeneratedOption.Computed)]
        public DateTimeOffset CreatedUtc { get; set; }

        [Timestamp]
        public byte[] RowVersion { get; set; }
    }
public class Company: ModelBaseWithId  {
        public string Name { get; set; }

        public string Description { get; set; }

        public string Domain { get; set; }

        public virtual ICollection<CompanyEnvironment> Environments { get; set; }
    }
public class CompanyEnvironment: ModelBaseWithId {

        public string Name { get; set; }

        public string Description { get; set; }

        public string ConnectionString { get; set; }

        public virtual Company Company { get; set; }

    }

register the odata endpoint as per documentation, and try to hit the following url

http://<serverAddress>/<configuredPath>/CompanyEnvironment?$expand=Company($count=true)&$count=true

the '$count=true' inside the expand causes a Value Null Exception, the count outside works as expected.

ArgumentNullException: Value cannot be null.
Parameter name: member

Expected result

all expanded items should have a count in the format "fieldName@odata.count":number

Actual result

either throws a exception on shows incorrect values

@biaol-odata biaol-odata added the P2 label Aug 9, 2018
@biaol-odata
Copy link
Contributor

Set to P2 due to NullValueExeception.

@NetTecture
Copy link

That is actually supposed to work?

I am asking because a similar URL does not even pass parsing in ODL libraries (which would be tracked under 809). This would actually possibly be a workaround one that is made working. So, this is actually supposed to work? NICE.

@gathogojr
Copy link
Contributor

Fixed by OData/odata.net#2051

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants