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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:57:09+00:00 2026-05-26T05:57:09+00:00

Ok, so basically I need to create a generic method which takes a list

  • 0

Ok, so basically I need to create a generic method which takes a list of frontend objects, retrieves the wrapped data object of each frontend object and returns a list of data objects.

I have written this method inside a singleton class.

public IEnumerable<T> GetDataItemsFromFrontend<T>(IEnumerable<T> frontendItems)
    {
        List<T> dataItems = new List<T>();
        foreach(T frontendItem in frontendItems)
            {
                dataItems.Add(T.GetDataItem());
            }
        return dataItems;
    }

Quite naturally, T.GetUser() does not exist. To give you a better idea of what I intend to do:

I have an entity object called User (generated by the Entity-Model Framework). To add functionality to User, I created a wrapper object called ClassFrontend where class is replaced by the entity title in question (for example, UserFrontend, RoleFrontend, etc).

I called the entity object inside the frontend class Data.

Now I would like to have a Generic method, which I give it a list of frontend items, and it gives me back a list of entity objects – naturally the list would be all of the same type: example all of UserFrontend, or all of RoleFrontend, etc.

Thanks.

  • 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-26T05:57:09+00:00Added an answer on May 26, 2026 at 5:57 am

    I would make the FrontEnd objects implement an interface like below:

    public interface IFrontEndEntity<TEntity>
    {
        TEntity GetEntity();
    }
    public static class FrontEndExtensions
    {
        public static IEnumerable<TEntity> GetEntities<TEntity>(this IEnumerable<IFrontEndEntity<TEntity>> frontEndItems)
        {
            return frontEndItems.Select(a => a.GetEntity());
        }
    }
    public class Dog
    {
    }
    public class DogFrontEnd : IFrontEndEntity<Dog>
    {
        public Dog Entity { get; set; }
        public Dog GetEntity()
        {
            return Entity;
        }
    }
    public class Main
    {
        public void Run()
        {
            IEnumerable<DogFrontEnd> dogFronEnds = new List<DogFrontEnd>();
            IEnumerable<Dog> dogs = dogFronEnds.GetEntities();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically I need a hosted solution, where one can create an account for a
I have a need to basically create a matrix of values in my Silverlight
I basically need to create a anchor that will navigate to a different port
I'm trying to create a generic data model that will allow for a particular
I need to create a query which checks if a field (string) contains one
I (Basically) need to create a background timer on iOS 4 that will allow
I need to create an algorithm to layout some hierarchical data but have never
I basically need to create a value by default for a drop down menu
Basically I need to create a client side Your session is about to expire....click
Basically I need some suggestions which is the best way to switch views 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.