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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:22:51+00:00 2026-06-01T04:22:51+00:00

Lets say I wish to be able to render different view logic for two

  • 0

Lets say I wish to be able to render different view logic for two different types, both are store items/products that will be used in search result views etc. Ultimately I would want the objects ordered according to a price property which both have, but of course they are still different types so I wonder if it is possible to order different object types in a list by using a property value of the same type on each?

I have a Product type and ProductCombo type.

Is it more optimal to store them in the model class as such (Probably can’t order them then):

public class
{

public List<Product> ProductList {get; set;}

public List<ProductCombo> ProductComboList {get; set;}

}

Or

public class
{

public List<object> StoreItems {get; set;}

}

If I use the above 2nd option I would of course have to unbox each object, get the type and decide what action to take for said type in the view. I think this is my best choice ? Considering that I would want to order the items in the List<object> by their decimal type price property.

Also another crude way to do it would be this I am guessing.

public class StoreItem
{
public Product product {get; set;}

public ProductCombo productCombo {get; set;}

public double itemPrice {get; set;} 

}

And then just store in List<StoreItem>
setting the itemPrice when doing a foreach on
each object returned from the database.

  • 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-01T04:22:53+00:00Added an answer on June 1, 2026 at 4:22 am

    Why not do something like this

    public interface IPricedItem
    {
        double Price { get; }
    }
    
    class Product : IPricedItem { ... }
    class ProductCombo : IPricedItem { ... }
    
    public class Whatever
    {
        public List<IPricedItem> StoreItems { get; set; }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets say I have an object that has stringProp1, stringProp2. I wish to store
Lets say I wish to make a page that can query the desired object
My question is i have a certain money amount, lets say 552. I wish
Let’s say you wish to have two classes like so, each declaring an instance
I have some integers, let's say one two and three . I wish to
Lets say that me and my friend are trying to work on same software
Lets say I have two functions: def foo(): return 'foo' def bar(): yield 'bar'
Lets say i have a rectangle Now i wish to apply it transformations such
I wish to create an index with, lets say the following fields : UID
Let's say I have one class Foo that has a bunch of logic in

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.