Skip to content

Issue with Inlinecount with navigation properties #63

@maganuk

Description

@maganuk

Hi,

I'm having some trouble with using the inlinecount with a child navigation property using projections.

Here are the classes:

public class Person
{
    public int ID { get; set; }
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public ICollection<Address> Addresses { get; set; }
}

public class Address
{
    public int ID { get; set; }
    public string FirstLine { get; set; }
    public string SecondLine { get; set; }
}

And here is the relevant code:

_unitOfWork.PersonRepository.GetDbSet()
.Select(p => new PersonDTO
{
ID = p.ID,
FirstName = p.FirstName,
LastName = p.LastName,
Address = p.Address.Select(x => new AddressDTO { Id = x.ID, FirstLine = x.FirstLine, SecondLine = x.SecondLine}).ToList()
})
.LinqToQuerystring(typeof(PersonDTO), query));

Everything works fine (including filtering, sorting) except when I introduce the Inlinecount=allpages querystring. The inner exception that i'm getting is:

"There is already an open DataReader associated with this Command which must be closed first."

If I do a ToList().AsQueryable() between the .linqToQueryString and the Select statement it works fine but that means that first the entire dataset is queried and then the filtering happens on the returned dataset. I would like to avoid that as we're dealing with a large dataset. Is there any way I can get the required data with a single call to the API?

Thanks
Best Regards

Vishal

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions