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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:26:16+00:00 2026-05-31T01:26:16+00:00

I have an object Topic which is a self-related hierarchy where the child Topics

  • 0

I have an object Topic which is a self-related hierarchy where the child Topics are defined as

public class Topic : Entity {
   public ISet<Topic> ChildTopics { get; internal set; }
   public Topic ParentTopic { get; set; }
   ...
}

I’m writing a form (MVC3) to produce a drop-down list (Html.DropDownListFor) of the first-level topics (theoretically this will eventually AJAX into a second drop-down for second-level topics), but when it goes to save, it produces the ever-popular “Cannot cast…” exception (see question title).

The usual cause of this is that you used List or Set instead of IList or ISet, but I am using ISet, and it specifically says it can’t cast to ISet.

The reason this is a set is because you wouldn’t want a Topic being a child of another Topic more than once. The table mapping create by Fluent NH automapping is correct with this override:

mapping.HasMany<Topic>(t => t.ChildTopics).AsSet().Inverse().KeyColumn("TopicId");

  • 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-31T01:26:18+00:00Added an answer on May 31, 2026 at 1:26 am

    In my project, as of NHibernate 3.2.0.400, this error still occurs if I use System.Collections.Generic.ISet<T> instead of Iesi.Collections.Generic.ISet<T>. Simply changing the references around is minimal work and solves the problem.

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

Sidebar

Related Questions

I have a class Topic and Group which both have a variable called 'name',
I have the following domain entity objects: public class Report { public virtual int
I have a Topic object which i created on the client-side iPhone. When I
I have object A which contains multiple instances of object B, which in turn
I have shared object A.so which statically links to libssl.a & another shared object
I have an object Foo that has an NSNumber property which is declared like
What I would like to do is have a common Service class which has
Currently I have a database object, vacancies which has a column (foreign key) CareerLevels.
I have searched all the questions related to this topic but i didnt find
I have been testing different features of Objective -C and reached topic which deals

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.