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 525153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:38:31+00:00 2026-05-13T08:38:31+00:00

I have the following class declaration: public class EntityTag : BaseEntity, ITaggable I have

  • 0

I have the following class declaration:

public class EntityTag : BaseEntity, ITaggable

I have an Html helper method:

public static string TagCloud(this HtmlHelper html, IQueryable<ITaggable> taggables, 
  int numberOfStyleVariations, string divId)

This is my ASP.NET MVC ascx:

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IQueryable<EDN.MVC.Models.EntityTag>>" %>
<%@Import Namespace="EDN.MVC.Helpers" %>
<%= Html.TagCloud(Model, 6, "entity-tags") %>

When I pass in an IQueryable collection to the ascx, I get this error:

Compiler Error Message: CS1928: ‘System.Web.Mvc.HtmlHelper>’ does not contain a definition for ‘TagCloud’ and the best extension method overload ‘EDN.MVC.Helpers.EdnHelpers.TagCloud(System.Web.Mvc.HtmlHelper, System.Linq.IQueryable, int, string)’ has some invalid arguments

If I try to explicitly convert the object collection with this:

    public static string TagCloud(this HtmlHelper html, IQueryable<Object> taggables, int numberOfStyleVariations, string divId)
    {
        var tags = new List<ITaggable>();
        foreach (var obj in taggables)
        {
            tags.Add(obj as ITaggable);
        }
        return TagCloud(html, tags.AsQueryable(), numberOfStyleVariations, divId);
    }

I get the same error – the values I’m passing in are not liked by the compiler.

Shouldn’t my EntityTag class automatically be supported as IQueryable? What am I missing? It’s got to be something obvious. (I hope.)

  • 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-05-13T08:38:31+00:00Added an answer on May 13, 2026 at 8:38 am

    Essentially, you’re trying to pass an object of the non-generic type IQueryable to a method that accepts the generic IQueryable<ITaggable>, which the compiler cannot “match”, resulting in the CS1928 (since the two types are, in fact, different).

    In your overload that accepts an IQueryable<object> (which is already doing the necessary conversion to a generic list), you simply need to call the generic version of AsQueryable instead of the non-generic one, as such:

    public static string TagCloud(this HtmlHelper html, IQueryable taggables, int numberOfStyleVariations, string divId)  
    {  
        var tags = new List<ITaggable>();  
        foreach (var obj in taggables)  
        {  
            tags.Add(obj as ITaggable);  
        }  
        return TagCloud(html, tags.AsQueryable<ITaggable>(), numberOfStyleVariations, divId);  
    }  
    

    Allow me to add, as well, that IQueryable<T> derives from IQueryable, meaning that not all IQueryable objects are IQueryable<T>, thus making the conversion necessary. If the situation were reversed, i.e. your “real” helper method was defined to handle IQueryable objects, then you certainly would have no problem passing an IQueryable<T> to that method (since all IQueryable<T> objects are, in fact, IQueryable).

    Per Craig Stuntz, a much more elegant solution using LINQ features:
    <%= Html.TagCloud(Model.Select(t => (ITaggable)t), 6, "entity-tags") %>. You can also use <%= Html.TagCloud(Model.Cast<ITaggable>(), 6, "entity-tags") %> if your queryable provider supports it.

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

Sidebar

Ask A Question

Stats

  • Questions 413k
  • Answers 413k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I'm not sure I understand your intent perfectly, but perhaps… May 15, 2026 at 8:22 am
  • Editorial Team
    Editorial Team added an answer You're trashing the heap. realloc can freely choose to return… May 15, 2026 at 8:22 am
  • Editorial Team
    Editorial Team added an answer Are you looking for a weighted random array? Check this… May 15, 2026 at 8:22 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.