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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:50:56+00:00 2026-06-01T09:50:56+00:00

I’m trying to return the result of a entity framework query into my own

  • 0

I’m trying to return the result of a entity framework query into my own dto class, at the same time as mapping my enum TradeType.

I’m getting the following error

The specified value is not an instance of type ‘Edm.Int32’ Parameter name: value

Any idea how to fix or a workaround?

Thanks

public IEnumerable<Trade> GetLiveTrades(string routeName)
{
    return _entities.Price.Where(p => p.StatusCode.Equals("A") && p.Period.PeriodYear <= DateTime.Now.Year+1 && p.Route.RouteCode.Equals(routeName)).
        Select(p => new Trade
                        {
                            Volume = (long) (p.Volume ?? 100), 
                            TradeType = (p.PriceTypeCode.Equals("O") ? TradeType.Seller : TradeType.Bidder),
                            Price = p.Price1,
                            TenorStartDate = p.Period.PeriodStartDate.Value,
                            TenorEndDate = p.Period.PeriodStartDate.Value,
                            TradeId = p.ID
                        }).ToList();
        }

public class Trade
{
    public long Volume { get; set; }
    public TradeType TradeType { get; set; }
    public double Price { get; set; }
    public DateTime TenorStartDate { get; set; }
    public DateTime TenorEndDate { get; set; }
    public Guid TradeId { get; set; }
}
  • 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-01T09:50:57+00:00Added an answer on June 1, 2026 at 9:50 am

    Enums in projections from Entity Framework projections (Select) is a know issue. If you do

    _entities.Price.Where(p => p.StatusCode.Equals("A") &&
        p.Period.PeriodYear <= DateTime.Now.Year + 1 &&
        p.Route.RouteCode.Equals(routeName)).ToList() // ToList !
        .Select(p => new Trade ...
    

    the projection is done by regular linq-to-objects, which is a routine job.


    EDIT

    As a late afterthought I’d like to add that just a dumb ToList() can be detrimental when the table in question has many columns. It would mean that far more data is transferred to the client than necessary. In such cases it can be useful to do a double projection. First, within the scope of the query provider project to accepted types. Then, after switching to linq-to-objects (AsEnumerable) project to the final type:

    _entities.Price.Where(p => p.StatusCode.Equals("A") &&
        p.Period.PeriodYear <= DateTime.Now.Year + 1 &&
        p.Route.RouteCode.Equals(routeName))
        .Select(p => new 
                    {
                      Volume = (long) (p.Volume ?? 100), 
                      PriceTypeCode = p.PriceTypeCode,
                      Price = p.Price1,
                      TenorStartDate = p.Period.PeriodStartDate.Value,
                      TenorEndDate = p.Period.PeriodStartDate.Value,
                      TradeId = p.ID
                    })
        .AsEnumerable()
        .Select(x => new Trade
                     {
                       Volume = x.Volume, 
                       TradeType = (x.PriceTypeCode.Equals("O") ? TradeType.Seller : TradeType.Bidder),
                       Price = x.Price1,
                       TenorStartDate = x.TenorStartDate,
                       TenorEndDate = x.TenorEndDate,
                       TradeId = x.ID
                     }).
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I am trying to render a haml file in a javascript response like so:
I am doing a simple coin flipping experiment for class that involves flipping a
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.