We use an existing database stored procedure, similar to the one below, which returns decimal output,
CREATE PROCEDURE spTest(@a int, @b decimal(18,2) output) as BEGIN SELECT @b=23.22 SELECT * FROM <TABLE> where id = @a END
When I call a stored procedure in a C # application (code below), I get the result for the output parameter as 23 instead of 23.22
ObjectParameter b = new ObjectParameter("b", typeof(System.Decimal)) var result = myentities.context.spTest(1234, b)
This is the exact same issue posted by Imre Horvath ( http://social.msdn.microsoft.com/Forums/en-US/14bdde82-c084-44dd-ad83-c1305cb966d2/decimal-output-parameter-rounded-to-integer ) , but the difference is that we use SQL Server 2008 and the essence of framework 5.0. After reading the sentence from my post, I opened the edmx file in the xml editor and noticed the following for the @b output parameter, as shown below,
<Parameter Name="b" Type="decimal" Mode="InOut"/>;
I changed it to
<Parameter Name="b" Type="decimal" Mode="InOut" Precision="18" Scale="2"/>;
and run the application and I got the result as expected (23.22)
This is work, but not a solution, because you know that changes will be lost when updating the stored procedure in the design of the entity framework. There is a lot of stored procedure in our database that has decimal (18,2) as output parameter. I am wondering, still the problem is in the essence of framework 5.0. Your help will be greatly appreciated.
Kumar
Kumar source share