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

  • Home
  • SEARCH
  • 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 7713903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:59:18+00:00 2026-06-01T01:59:18+00:00

I have a IRecord object that can hold objects. The name of these objects

  • 0

I have a IRecord object that can hold objects. The name of these objects is saved in mapping as Properties. I loop through the properties and get them out of the IRecord by doing

record[property]

These objects are always ICollections. However, I don’t know what type the ICollection will hold before hand. How can I unbox the object to the right ICollection without knowing what the ICollection will hold?

The code below is a working version if record[property is an IColletion, so I want to change this that it can take any ICollection.

public ElectronicSignatureModel SignHierarchy(IRecord record, List<HierarchyMapping> mapping)
    {
        foreach (HierarchyMapping hierarchyMapping in mapping)
        {

            string[] propertyList = hierarchyMapping.Properties;
            foreach (string property in propertyList)
            {
                ICollection<Sample> recordProperty = (ICollection<Sample>)record[property];
            }
        }
  • 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-01T01:59:20+00:00Added an answer on June 1, 2026 at 1:59 am

    You can use .NET reflection to dynamically get value of a property in a object in the runtime. even you can use it to invoke a method or or create class instance.

    You can try something like the following code:

    foreach (string property in propertyList)
    {
        PropertyInfo pinfo = record.GetType().GetProperty(property);
        var recordProperty = pinfo.GetValue(record, null);
    }
    

    the “recordProperty” should have the right ICollection now, then you can use it.

    You can read more about .NET reflection here:

    Reflection in .NET
    http://www.codeproject.com/Articles/55710/Reflection-in-NET

    Reflection in the .NET Framework
    http://msdn.microsoft.com/en-us/library/f7ykdhsy(v=vs.100).aspx

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

Sidebar

Related Questions

I have tried almost everything and I can't seem to get my lists to
I have a question about equivalent search result, that can occur on different fields.
I have a page that displays two objects and then the user picks one
Have you managed to get Aptana Studio debugging to work? I tried following this,
Greeting, I have a problem with flash media live encoder CS5 that when I
I have written an application (using Delphi 2009) that allows a user to select
I am using Tao framework and I have a simple opengl control. How can
If I record an audio file and I have a core data object representing
I have an application that shows some data in p:DataTable.... This table is accessible
I have designed a basic search in ASP/C# for searching through records in a

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.