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

Issue with Inlinecount with navigation properties #63

Open
maganuk opened this issue Nov 17, 2015 · 0 comments
Open

Issue with Inlinecount with navigation properties #63

maganuk opened this issue Nov 17, 2015 · 0 comments

Comments

@maganuk
Copy link

maganuk commented Nov 17, 2015

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

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

No branches or pull requests

1 participant