1

I have to use...

Code of C#

public double price { get; set; }

Code of SQL

Select id, (0.0) AS price from Product

but during this code I got this error:

"ExceptionMessage":"The specified cast from a materialized 'System.Decimal' type to a nullable 'System.Double' type is not valid."

Also I don't want to change code of c#, For solving I want to change code of Sql (not c#)

1
  • cast your sql value to double in C# side price = (double) dbValue Commented Jun 9, 2016 at 6:16

1 Answer 1

1

The (0.0) return a numeric type, which is mapped to Decimal. All you need is to cast into float, which is mapped to double, so :

SELECT id, cast(0.0 as float) AS price from Product

should do the trick.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.