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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:58:00+00:00 2026-05-27T14:58:00+00:00

I have a 3rd party application that provides an object with many attributes, which

  • 0

I have a 3rd party application that provides an object with many “attributes”, which are simply pairs of (string) keys and values. The value types can be either strings, DateTime, Int32 or Int64.

I need to create my own class to represent this object, in a convenient way. I’m creating a WCF service that provides this object to clients, so I need it to be very easy and clean.

The keys of the attributes will be presented as an Enum for the clients (to hide the information of the specific key strings of the 3rd party application). However, I’m not sure how to represent the values. Here are some of the options:

Option 1: Have different collection per attribute values, seems ugly but will be very easy for clients to use

public class MyObject
{
    public Dictionary<MyTextAttributeKeysEnum, string> TextAttributes { get; set; }
    public Dictionary<MyDateAttributeKeysEnum, DateTime> DateAttributes { get; set; }
    public Dictionary<MyNumAttributeKeysEnum, long> NumericAttributes { get; set; }

    public string Name { get; set; }
    public string Id{ get; set; }

Option 2: Convert all of the attributes to strings

public class MyObject
{
    public Dictionary<MyAttributeKeysEnum, string> MyAttributes { get; set; }

    public string Name { get; set; }
    public string Id{ get; set; }

Option 3: Keep them as objects, let the clients bother with casting and converting

public class MyObject
{
    public Dictionary<MyAttributeKeysEnum, object> MyAttributes { get; set; }

    public string Name { get; set; }
    public string Id{ get; set; }
  • 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-27T14:58:01+00:00Added an answer on May 27, 2026 at 2:58 pm

    Using several dictionaries just doesn’t look nice 🙂 But might work in some scenarios.

    If you are absolutely sure that string is enough for all – go with strings. But if some other code would need to parse it – that’s going to be expensive.

    If you want a really simple straightforward solution – just go with objects. Even though it would introduce boxing/unboxing for value types (forget it if you don’t operate thousands of objects) and you’d lose type information on values this solution might still work just fine.

    Also you might consider introducing an intermediate class for a value. Something like

    public Dictionary<MyAttributeKeysEnum, PropertyBagValue> MyAttributes { get; set; }
    
    public class PropertyBagValue
    {
        public object AsObject { get; set; }
        public string AsString { get; set; }
        public int AsInt { get; set; }
        // ...
    }
    

    Internally you could store your value in a variable of the original type (int in an int variable, string in a string variable, etc., i.e. have a separate variable for each type) and then you can avoid type conversion. Also you could wrap your dictionary in another class, add some usefull accessors and make it look nicer. I don’t know how does this fit into your infrastructure though.

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

Sidebar

Related Questions

I have a Unicode Win32 application that uses 3rd party libraries, some of which
so I have a 3rd party application that I have to interface with, this
I have a stored proc on an existing 3rd party application (SQL 2005) that
I have a Windows application that utilizes a 3rd-party tool ( FaxMan ) to
I have a 3rd party application that doesn't come with an installer. It's a
I have an XSLT that I input to a 3rd party application. This application
I have a (REST) application that handles CRUD operations initiated by a 3rd party,
I have a Rails application that queries a 3rd party web service. I am
I have a 3rd party application from which I need to copy texts and
I have a website in ASP.Net that generates PDF with a 3rd party application

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.