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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:54:38+00:00 2026-05-17T20:54:38+00:00

I’m trying to implement a class in a Silverlight 4 RIA Services application that

  • 0

I’m trying to implement a class in a Silverlight 4 RIA Services application that manages different ObservableCollections that are used for data binding. These ObservableCollections need to be identified by a string name and an integer classID, which I have implemented by nesting Dictionary objects in a Dictionary> object. The problem is, if I have explicit Entity types (which I do), this structure does not seem to work. The problem seems to occur when I am trying to put an ObservableCollection into an ObservableCollection (my guess as to how a generic entity list would be implemented).

For example:

  this.rawData = new Dictionary<int, ObservableCollection<DataRaw>>();
  this.constData = new Dictionary<int, ObservableCollection<SystemConstant>>();

  this.masterData = new Dictionary<string, Dictionary<int, ObservableCollection<Entity>>>();

  masterData.Add("test", rawData);  <--- ERROR OCCURS HERE, 'best overloaded method has invalid arguments'

Note that I have tried using ‘Object’ instead of ‘Entity’ in the instantiation of masterData, but that did not solve the problem (it was admittedly a feeble attempt).

Thanks in advance for your insights. If there is a much better pattern I could be implementing here, I am open to being flexible. I mainly want to avoid having to code a bunch of Entity-type specific logic to manage the updating of this class. It seems like this should be generalizable.

Alex

  • 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-17T20:54:38+00:00Added an answer on May 17, 2026 at 8:54 pm

    For this to work you will have to declare RawData using the parent type, like this:

     this.rawData = new Dictionary<int, ObservableCollection<Entity>>();
    

    Even if this dictionary will only hold instances of DataRaw, and even if DataRaw is derived from Entity, it is not possible to make an implicit conversion between ObservableCollection<DataRaw> and ObservableCollection<Entity>. For a moment I hesitated on whether C# would be able to solve this using variance, but after a quick proof of concept it was clear it cannot:

            var dataRaw = new DataRaw();
            Entity testEntity = dataRaw;
    
            var entityObservable = new ObservableCollection<Entity>();
    
            entityObservable.Add(dataRaw); // This is OK
    
            var dataRawObservable = new ObservableCollection<DataRaw>();
            dataRawObservable.Add(dataRaw); // This is fine too.
    
            entityObservable = dataRawObservable; // This is not valid
    
            var metaDictionary = new Dictionary<Int32, ObservableCollection<Entity>>();
    
            metaDictionary.Add(1, dataRawObservable); // This isn't valid either.
    
            metaDictionary.Add(2, entityObservable); // This is valid.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.