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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:33:17+00:00 2026-05-26T20:33:17+00:00

I have a web service that returns a decimal value into my json string

  • 0

I have a web service that returns a decimal value into my json string but it rounds it off on numbers that are 400.00 to 400 instead, but if it has 400.50 it returns 400.50 which is what i want how do i return a value that is 400 to 400.00 in that format

Error

{"Message":"LINQ to Entities does not recognize the method \u0027System.String ToString(System.String)\u0027 method, and this method cannot be translated into a store expression.","

Code

    Products = (
    from p in db.Products where p.DepartmentId == qDepartment.Id
    join i in db.ProductImages on p.Id equals i.ProductId into products
    from x in products.Where(y => y.Dimension == "180X180")
    select new Product
    {
        Id = p.Id,
        Title = p.Title,
        ShortDescription = p.ShortDescription,
        Brand = p.Brand,
        Model = p.Model,
        Image = x.Path,
        FriendlyUrl = p.FriendlyUrl,
        SellPrice = p.SellPrice.ToString("N2")/*Error Here changed type to string*/,
        DiscountPercentage = p.DiscountPercentage,
        Votes = p.Votes,
        TotalRating = p.TotalRating
    }).ToList();

  • 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-26T20:33:17+00:00Added an answer on May 26, 2026 at 8:33 pm

    Whether you return 400, or 400.00 should not matter for anything mathematical so I’m assuming that this is regarding displaying a decimal to a user. In this case you can supply a string format to decimal’s ToString().

    decimal number = 400m;
    Console.WriteLine(number.ToString("N2")); // Outputs 400.00
    

    This will always return up to two decimal places. Please note however, that it is no longer a number at this point, but a string. If you are using the webservices’ JSON for both display and math then I suggest returning the decimal, and formatting the string client side through javscript number.toFixed(2);

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

Sidebar

Related Questions

I have a web service that returns a raw string of JSON data (sample
I have a web service that returns an xml string as results. The return
I have access to an web service that returns an XML or JSON. Since
I have a web service that returns a base64 encoded string of a PDF
I have a WCF web service that returns a string to a Java based
I have a web service that returns a JSON object. The response consists of
I have a web-service that returns a custom object, but now I want to
I have a WCF web service that returns JSON data back to an app
I have a RESTful web service that returns JSON-serialized data. It can successfully serialize
I have a web service that returns a string of svg code. My problem

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.