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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:59:04+00:00 2026-05-30T20:59:04+00:00

Good day, My code generates a run-time error and I’m not sure how to

  • 0

Good day,

My code generates a run-time error and I’m not sure how to fix this. Any help would be appreciated.

Our code is calling the second Convert method below by passing a list of “offers”. The offer is an object from an EDMX model. The first Convert method takes the object and converts it to a DTO class which it then returns back.

When running the program, I experience the following error:

LINQ to Entities does not recognize the method ‘…Domain.Holdings.OfferDto Convert(…Repository.Offer, System.Nullable`1[System.Int32])’ method, and this method cannot be translated into a store expression.

The code looks as follows:

public class OfferDtoMapping
{
    public static OfferDto Convert(Offer offer, int? participantId)
    {
        if (offer == null)
            throw new ArgumentException("The Offer object supplied for conversion cannot be null");

        var unitCost = offer.UnitCost;
        if (offer.Trust.Company.AllowInterDiv && participantId.HasValue)
        {
            Assign another value to unitCost...
        }

        var output = new OfferDto
        {               
            Assign the offer properties to the OfferDto properties...
        };
        return output;        
    }

    public static IList<OfferDto> Convert(IQueryable<Offer> offerList)
    {
        return offerList == null ? new List<OfferDto>() : offerList.Select(ol => Convert(ol, null)).ToList();
    }
}

The error occurs on this line:

 return offerList == null ? new List<OfferDto>() : offerList.Select(ol => Convert(ol, null)).ToList();

I suspect the error has to do with the fact that I am projecting the offerList over a method taking in 2 input parameters. We tried passing 0 instead of NULL (because we initially thought that was the problem) but still got a similar error message.

In order to maintain consistency throughout our solution we want to keep using the Select method instead of replacing this with a foreach statement.

Is there a way of using the Select method in our current situation?

Thank you in advance.

  • 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-30T20:59:05+00:00Added an answer on May 30, 2026 at 8:59 pm

    The error occurs because there is no transaltion for the Convert method in Linq to entities. You need to force evaluation of the data first by calling ToList() on the Iqueryable data. The convert can then be executed outside of Linq to Entites in memory.

    return offerList == null ? new List<OfferDto>() : offerList.ToList().Select(ol => Convert(ol, null)).ToList();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Good day all; I am not sure what has changed to prevent this from
Good day, could you please help me look and this code and tell me
Good day, first I would like to tell that I am not proud to
Good Day All we are trying to do is inside a trigger make sure
Good day everybody! Having the following code: template<typename T, typename OutStream = std::ostream> struct
Hello and good day to you. Following code fragment compiles on cl.exe (15.00.30729.01) and
Hello and good day to all. I have the following code to retrieve from
Good day code knights, I have a tricky problem that I cannot see a
Good day coders and codereses, I am writing a piece of code that goes
Good day! I am trying to disable access on pages that are not part

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.