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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:53:46+00:00 2026-06-15T11:53:46+00:00

I am receiving the following error when testing to run a report: LINQ to

  • 0

I am receiving the following error when testing to run a report:

LINQ to Entities does not recognize the method ‘System.Decimal PerformCurrencyConversion(System.Decimal, System.Decimal, System.Decimal, System.String, System.DateTime)’ method, and this method cannot be translated into a store expression.

Here is my query:

List<BusinessPlanningElements> productSales = (from sale in ctn.ProductSales
    where sale.DateSold.Year == reportRequest.Year && sale.ProductID == t.ProductID
    group sale by sale.DateSold.Month into ds
    select new BusinessPlanningElements
    {
      Month = ds.Select(it => it.DateSold.Month).FirstOrDefault(),
      EURNumberOfUnitSold = ds.Where(it => it.EURSales.HasValue).Where(it => it.EURSales != 0).Count(),
      GBPNumberOfUnitSold = ds.Where(it => it.GBPSales.HasValue).Where(it => it.GBPSales != 0).Count(),
      USDNumberOfUnitSold = ds.Where(it => it.USDSales.HasValue).Where(it => it.USDSales != 0).Count(),
      EURCumulativeNumberOfUnitsSold = ctn.ProductSales.Where(it => it.EURSales.HasValue && it.EURSales != 0 && it.ProductID == t.ProductID && it.DateSold.Month <= ds.Key).Count(),
      GBPCumulativeNumberOfUnitsSold = ctn.ProductSales.Where(it => it.GBPSales.HasValue && it.GBPSales != 0 && it.ProductID == t.ProductID && it.DateSold.Month <= ds.Key).Count(),
      USDCumulativeNumberOfUnitsSold = ctn.ProductSales.Where(it => it.USDSales.HasValue && it.USDSales != 0 && it.ProductID == t.ProductID && it.DateSold.Month <= ds.Key).Count(),
      USDTotalSales = PerformCurrencyConversion(ds.Sum(it => it.USDSales.HasValue ? it.USDSales.Value : 0), 0M, 0M, reportRequest.Currency, DateTime.Now.AddMonths(-2)),
      GBPTotalSales = PerformCurrencyConversion(0M, ds.Sum(it => it.GBPSales.HasValue ? it.GBPSales.Value : 0), 0M, reportRequest.Currency, DateTime.Now.AddMonths(-2)),
      EURTotalSales = PerformCurrencyConversion(0M, 0M, ds.Sum(it => it.EURSales.HasValue ? it.EURSales.Value : 0), reportRequest.Currency, DateTime.Now.AddMonths(-2)),
      USDCumulativeTotalSales = PerformCurrencyConversion(ctn.ProductSales.Sum(it => it.USDSales.HasValue && it.USDSales != 0 && it.ProductID == t.ProductID && it.DateSold.Month <= ds.Key ? it.USDSales.Value : 0), 0M, 0M, reportRequest.Currency, DateTime.Now.AddMonths(-2)),
      GBPCumulativeTotalSales = PerformCurrencyConversion(ctn.ProductSales.Sum(it => it.GBPSales.HasValue && it.GBPSales != 0 && it.ProductID == t.ProductID && it.DateSold.Month <= ds.Key ? it.GBPSales.Value : 0), 0M, 0M, reportRequest.Currency, DateTime.Now.AddMonths(-2)),
      EURCumulativeTotalSales = PerformCurrencyConversion(ctn.ProductSales.Sum(it => it.EURSales.HasValue && it.EURSales != 0 && it.ProductID == t.ProductID && it.DateSold.Month <= ds.Key ? it.EURSales.Value : 0), 0M, 0M, reportRequest.Currency, DateTime.Now.AddMonths(-2)),
    }).ToList();

The PerformCurrencyConversion method pretty much gets a list of conversion rates, and converts the value to the currency which is specified by the user. It accepts parameters like so:

public decimal PerformCurrencyConversion(decimal usd, decimal gbp, decimal eur, string Currency, DateTime saleMonth)
{
    //Logic
}

I have used this method several times in the past throughout the codebase with no trouble or errors, e.g.

List<MonthlyProductSales> monthlyProductSales = (from sale in productSales
     orderby sale.DateSold descending
     group sale by new { sale.DateSold.Month, sale.Product.Name } into ds
     select new MonthlyProductSales
     {
         Name = ds.Select(it => it.Product.Name).FirstOrDefault(),
         Month = ds.Select(it => it.DateSold.Month).FirstOrDefault(),
         Year = ds.Select(it => it.DateSold.Year).FirstOrDefault(),
         USDNumberItemsSold = ds.Where(it => it.USDSales.HasValue).Where(it => it.USDSales != 0).Count(),
         GBPNumberItemsSold = ds.Where(it => it.GBPSales.HasValue).Where(it => it.GBPSales != 0).Count(),
         EURNumberItemsSold = ds.Where(it => it.EURSales.HasValue).Where(it => it.EURSales != 0).Count(),
         USDRevenueTotal = PerformCurrencyConversion(ds.Sum(it => it.USDSales.HasValue ? it.USDSales.Value : 0), 0M, 0M, reportRequest.Currency, DateTime.Now.AddMonths(-2)),
         GBPRevenueTotal = PerformCurrencyConversion(0M, ds.Sum(it => it.GBPSales.HasValue ? it.GBPSales.Value : 0), 0M, reportRequest.Currency, DateTime.Now.AddMonths(-2)),
         EURRevenueTotal = PerformCurrencyConversion(0M, 0M, ds.Sum(it => it.EURSales.HasValue ? it.EURSales.Value : 0), reportRequest.Currency, DateTime.Now.AddMonths(-2)),
     }).ToList();

Can anyone see what the difference is, or how I might get around this error?

  • 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-15T11:53:48+00:00Added an answer on June 15, 2026 at 11:53 am

    The difference is in the LINQ implementation.

    In the first code sample, you are using LINQ to Entities (i.e., the LINQ implementation of Entity Framework). This implementation translates your LINQ into SQL which is eventually executed on the database.

    In the 2nd code sample, you are using LINQ to Objects (i.e., in-memory collections). This implementation does not translate to SQL or another language, but simply creates a chain of actions that are executed on in-memory collections. Therefore, this implementation of LINQ can use .NET functions such as PerformCurrencyConversion.

    So what you can do is first query your database using LINQ to Entities, and store the results in an array or list, and then do a LINQ to Objects query on that array or list — and then you can use built-in .NET functions.

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

Sidebar

Related Questions

I am receiving the following error: System.InvalidOperationException was unhandled Message=The type 'Judge' is not
I am receiving an error on the following line of code: Object reference not
Im receiving the following error Name 'Encryption' is not declared. On Line If reader_login(password).ToString()
I am using VBA for Excel 2010 and randomly receiving the following error: Run-time
I am receiving the following error when I attempt to run my Spring JUnit
I am receiving the following error when I try to run my Xcode iOS
I am receiving the following error: Cannot implicitly convert type 'System.Collections.Generic.IEnumerable' to 'Munchkin.Model.PlayerProfiles.Profile'. An
I'm receiving the following error when I run collectstatic: AttributeError: 'cStringIO.StringO' object has no
Background I'm receiving the following error when trying to render a partial view in
I am receiving the following error in PHP Notice undefined offset 1: in C:\wamp\www\includes\imdbgrabber.php

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.