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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:41:48+00:00 2026-06-10T00:41:48+00:00

I have the following Project model: public class Project { [Key] public int ProjectID

  • 0

I have the following Project model:

public class Project
{
    [Key]
    public int      ProjectID       { get; set; }
    public string   Name            { get; set; }
    public string   Description     { get; set; }     
    public virtual  ICollection<Screenshot> Screenshots { get; set; }   
}

And I have the following Screenshot model:

public class Screenshot
{
    [Key]
    public int    ScreenshotID { get; set; }
    public string ScreenshotName { get; set; }
    public byte[] ScreenshotContent { get; set; }
    public string ScreenshotContentType { get; set; }
}

As you can see, each project have some screenshots attached. In the following function, I would like to retrieve some projects and only the ID of the corresponding screenshots.

public SearchResultDTO<ProjectDTO> GetProjects(SearchParametersProjectDTO dto)
{
    ...
    var resultDTO = new SearchResultDTO<ProjectDTO>
    {
        Entities = Mapper.Map<IEnumerable<Project>, IEnumerable<ProjectDTO>>(projects.ToList()),
        TotalItems = projects.Count()
    };
    return resultDTO;
}

Here is the ProjectDTO:

[DataContract]
public class ProjectDTO : BaseDTO<ProjectDTO, Project>
{
    [DataMember]
    public int ProjectID { get; set; }

    [DataMember]
    public string Name { get; set; }

    [DataMember]
    public string Description { get; set; }

    [DataMember]
    public IEnumerable<int> ScreenshotID { get; set; }

So I don’t know how to map ScreenshotID in my DTO.

Any help is greatly appreciated.

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-06-10T00:41:50+00:00Added an answer on June 10, 2026 at 12:41 am

    Create a mapping between Screenshot and int:

    Mapper
        .CreateMap<Screenshot, int>()
        .ConvertUsing(s => s.ScreenshotID);
    

    and inside the mapping between Project and ProjectDTO use it:

    Mapper
        .CreateMap<Project, ProjectDTO>()
        .ForMember(
            dest => dest.ScreenshotID,
            opt => opt.MapFrom(src => src.Screenshots)
        );
    

    And when you want to map:

    var project = new Project
    {
        Screenshots = new[]
        {
            new Screenshot { ScreenshotID = 1 },
            new Screenshot { ScreenshotID = 2 },
            new Screenshot { ScreenshotID = 3 },
        }
    };
    
    var projectDto = Mapper.Map<Project, ProjectDTO>(project);
    
    // at this stage the projectDto.ScreenshotID collection will contain 
    // the necessary information
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following entity model: public class Project { [Key] public int ProjectID
I have a class: public class Car { public string Model {get;set;} public string
Given domain model... public class Entity { public int Id { get; set; }
I have the following model in a project: class CarAssignment(models.Model): leg = models.ForeignKey(Leg, null=True,
I'm programming in MVC3 and i have the following model : public class L_CabecRegistoPedido
I have the following models in my ASP.NET MVC 3 project: public class Task
I have the following controller @Controller @RequestMapping(/project/view.html) public class ProjectViewController { private static final
In an MVC project I have the following classes: public abstract class Browse<T> where
I have a Python project with following directory structure: /(some files) /model/(python files) /tools/(more
I currently have the following models/toy.rb file in my RoR project: class ToysPurchased include

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.