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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:22:37+00:00 2026-06-13T11:22:37+00:00

Here is my method and i would like to cast my return – also

  • 0

Here is my method and i would like to cast my return – also i am doing this to prevent from changing my different methods i have and wanted to also know will this have any negative affect if a cast my return?

public VisitEntry Get(Guid visitEntryId)
    {
        var visitEntry = _visitEntryRepository.Get(visitEntryId);
        VisitEntryDTO dto = AutoMapper.Mapper.Map<VisitEntry, VisitEntryDTO>(visitEntry);
        dto.CasePartyIds =
            _casePartyService.GetAllForHearingEntry(visitEntryId).Select(caseParty => caseParty.CasePartyId).ToList();
        return dto;
    }

The error i get is for: return dto. Stating: that I cannot converty …Entity.VisitEntryDTO to …Entity.VisitEntry.

any clarification will be great. 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-13T11:22:38+00:00Added an answer on June 13, 2026 at 11:22 am

    You likely can’t directly cast from VisitEntryDTO to VisitEntry. You’ll need to Automap back.

    However, your repository seemingly already returns VisitEntry objects, so why are you mapping to a VisitEntryDTO in the first place? Why not just do:

    public VisitEntry Get(Guid visitEntryId)
    {
        var visitEntry = _visitEntryRepository.Get(visitEntryId);
        visitEntry.CasePartyIds =
            _casePartyService.GetAllForHearingEntry(visitEntryId).Select(caseParty => caseParty.CasePartyId).ToList();
        return visitEntry;
    }
    

    Unless I’m missing something about your VisitEntry class.

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

Sidebar

Related Questions

I'm doing code generation with C# and I would like to cast a backing
I have a method that returns byte[] but for now would like to avoid
I am reading in from my web.sitemap file, and I would like to apply
I'm not totally convinced this is possible, but here goes. I have a method
I would like my BallUserInterfaceFactory to return an instance of a user interface that
I would like to know why the generic method below does not compile (C#
Here is what I would like to write in my java code: private <A
I have carried the method here on almost all of the areas where I
First, I'm speaking about the default hashCode() method here and not something overridden. When
Here's the method. I want to know if I am violating any best practices

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.