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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:54:18+00:00 2026-06-07T03:54:18+00:00

I have a list view which is basically receiving a model of type IEnumerable(Thing).

  • 0

I have a “list” view which is basically receiving a model of type IEnumerable(Thing). I have no control over Thing; it is external.

That’s been nearly fine. One of the properties of ‘Thing’ is an enum of flags. I’d like to improve the formatting of this property in the view. I have read some strategies for that. My plan was to create a ViewModel that knows better about formatting.

I’d like to know if there’s a direct way to create an IEnumerable(ViewThing) from IEnumerable(Thing).

An obvious way would be to iterate through the IEnumerable of Things where for each Thing I would create a ViewThing and stuff it with the Thing’s data, resulting in an IEnumerable of ViewThings.

But backing up, I’m also interested in smarter ways to handle formatting the flags for viewing.

  • 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-07T03:54:19+00:00Added an answer on June 7, 2026 at 3:54 am

    You could use AutoMapper to map between your domain models and view models. The idea is that you define a mapping between Thing and ThingViewModel and then AutoMapper will take care of mapping collections of those objects so that you don’t have to iterate:

    public ActionResult Foo()
    {
        IEnumerable<Thing> things = ... get the things from whererver you are getting them
        IEnumerable<ThingViewModel> thingViewModels = Mapper.Map<IEnumerable<Thing>, IEnumerable<ThingViewModel>>(things);
        return View(thingViewModels);
    }
    

    Now all that’s left is define the mapping between a Thing and ThingViewModel:

    Mapper
        .CreateMap<Thing, ThingViewModel>().
        .ForMember(
            dest => dest.SomeProperty,
            opt => opt.MapFrom(src => ... map from the enum property)
        )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a model that contains an IEnumerable of a list of custom objects.
I have chat list view in which sender name should be left aligned and
I'm trying to use a list of clients that have been created from my
I have used a customized list view in which i have added 4 TextView
I have a list of Person s each which have multiple fields that I
I have a XAML view with a list box: <control:ListBoxScroll ItemSource={Binding Path=FooCollection} SelectedItem={Binding SelectedFoo,
I'm trying to create a custom list which will have checkboxes that allow you
I have a list view that has a column databound to a list.Count see
I have a list of places in listview which i got from parsing JSON.
Let's say I have an Index view. The model I pass in is actually

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.