Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9274361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T16:20:10+00:00 2026-06-18T16:20:10+00:00

Sequence contains more than one element at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source) at System.Web.Http.OData.Builder.ODataConventionModelBuilder.RemoveBaseTypeProperties(EntityTypeConfiguration derivedEntity, EntityTypeConfiguration baseEntity)

  • 0

Sequence contains more than one element
at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source) at
System.Web.Http.OData.Builder.ODataConventionModelBuilder.RemoveBaseTypeProperties(EntityTypeConfiguration derivedEntity, EntityTypeConfiguration baseEntity)
at System.Web.Http.OData.Builder.ODataConventionModelBuilder.DiscoverInheritanceRelationships()…

Here’s my binding code:

var modelBuilder = new ODataConventionModelBuilder();
modelBuilder.EntitySet<PeopleDto>("People");

Here’s my Controller code:

[Queryable]
public IEnumerable<PeopleDto> Get(
        [FromUri] Credentials credentials, 
        ODataQueryOptions<PeopleDto> options, 
        int departmentId,
        DetailLevel detail = DetailLevel.Low)
{
    var count = _repository.Filter(x => x.DepartmentId == departmentId && x.Active);
    options.ApplyTo(count);
    int total = count.Count();

    switch (detail)
    {
        case DetailLevel.Low:
            return new Paginable<PeopleDto>(GetMyPeopleLo(departmentId, options), total);
        // [...]
    }
}

Paginable<T> implements IEnumerable<T>. And the GetMyPeopleLo() (not the real name) method applies the options to the additional queries. (I don’t need additional queries anymore, because I have moved the location of the pagination code, but I just haven’t refactored that part yet).

Is this one of those cases where there’s an issue with the pre-release version of oData?

Update: If I comment out the Queryable attribute, it seems to work, but any filter that I specify in the querystring is not actually applied when options are applied to the count query.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T16:20:11+00:00Added an answer on June 18, 2026 at 4:20 pm

    A couple things jump out here:

    • You shouldn’t be using [Queryable] and ODataQueryOptions. They’re used for doing the same thing.
      In this case, ODataQueryOptions seems more appropriate so you should just remove [Queryable].
    • You’re not using the results of your query. Instead of this

      var count = _repository.Filter(x => x.DepartmentId == departmentId && x.Active);
      options.ApplyTo(count);
      int total = count.Count();
      

      You should be writing this:

      var count = _repository.Filter(x => x.DepartmentId == departmentId && x.Active);
      var queryResults = options.ApplyTo(count) as IQueryable<PeopleDto>;
      int total = queryResults.Count();
      

      That way your total will take into account the OData query options.

    • Consider using PageResult<T> instead of Paginable since the OData formatters will take the count and insert it correctly into the OData feed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For my function IEnumerable<CallbackListRecord> LoadOpenListToProcess(CallbackSearchParams usp); This line errors when the sequence contains no
I want to find if a string contains a repeated sequence of a known
In UML sequence diagram a method can have only one return line (at least
I have this web app that is running ASP .NET MVC 1.0 with LINQ
I have a web service that returns a dataset object that contains the current
I try to query data using FluentNhibernate and I get this error: Sequence contains
I've created a console application focused on C#3.5 and added a reference to System.Web,
I have a large file which contains sequence of characters like ABCDEabcde.....XYZxyz. Now, I
This sequence satisfies a(n+2) = 2 a(n+1) + 2 a(n). and also a(n)=[(1+sqrt(3))^(n+2)-(1-sqrt(3))^(n+2)]/(4sqrt(3)). I
Given sequence : [1,A,B,C,2,F,K,L,5,6,P,I,E] The numbers represent items that I identify as headers, whereas

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.