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

"ArgumentNullException: Value cannot be null. Parameter name: provider" error occurs when accessing certain navigation properties after Skip() #3844

Closed
cda-1 opened this issue Nov 22, 2015 · 1 comment
Assignees
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Milestone

Comments

@cda-1
Copy link

cda-1 commented Nov 22, 2015

Minimal repro steps

Create these two entities.

public class Property
{
    public int Id { get; set; }

    [Required]
    public int EmployeeId { get; set; }
    public Employee Employee { get; set; }
}
public class Employee
{
    public int Id { get; set; }

    [StringLength(256)]
    public string FirstName { get; set; }
}

This will work:

var testNav = await AppContext.Properties
    .Select(p => p.Employee.FirstName)
    .ToListAsync();

But this will not work (see exception below):

var testNav = await AppContext.Properties
    .Skip(20)
    .Select(p => p.Employee.FirstName)
    .ToListAsync();

You can select the p.Employee.Id after the skip, but not p.Employee.FirstName. Both work without the skip.

Expected result

You should be able to use .Select() after .Skip() and access navigation properties. It works fine in EF6 (although EF6 requires an OrderBy before the Skip). Using OrderBy before skip does not fix the issue in EF7.

Actual result

System.ArgumentNullException: Value cannot be null.
Parameter name: provider
    at Microsoft.Data.Entity.Utilities.Check.NotNull[T](T value, String parameterName)
    at Microsoft.Data.Entity.Query.Internal.EntityQueryable`1..ctor(IAsyncQueryProvider provider)
    at Microsoft.Data.Entity.Query.ExpressionVisitors.Internal.NavigationRewritingExpressionVisitor._CreateEntityQueryable[TResult](IAsyncQueryProvider entityQueryProvider)
@cda-1 cda-1 changed the title "ArgumentNullException: Value cannot be null." error occurs when accessing certain navigation properties after Skip() "ArgumentNullException: Value cannot be null. Parameter name: provider" error occurs when accessing certain navigation properties after Skip() Nov 22, 2015
@rowanmiller rowanmiller added this to the 7.0.0 milestone Nov 24, 2015
@rowanmiller rowanmiller modified the milestones: 7.0.0-rc2, 7.0.0 Dec 2, 2015
@mikary mikary assigned mikary and unassigned anpete Dec 18, 2015
@mikary
Copy link
Contributor

mikary commented Dec 18, 2015

Same issue as #3962
Addressed in #4128

@mikary mikary closed this as completed Dec 18, 2015
@ajcvickers ajcvickers modified the milestones: 1.0.0-rc2, 1.0.0 Oct 15, 2022
@ajcvickers ajcvickers added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Oct 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Projects
None yet
Development

No branches or pull requests

5 participants