zzzprojects / EntityFrameworkExtras

EntityFrameworkExtras provides some useful additions to EntityFramework such as executing Stored Procedures with User-Defined Table Types and Output Parameters.
https://entityframework-extras.net/
MIT License
80 stars 40 forks source link

error with floating point types when system decimal separator is not . #5

Closed dimeptr closed 10 years ago

dimeptr commented 10 years ago

on systems that use different decimal separator than . there is problem with decimal numbers in Table Valued Parameters. The following patch fixes the problem by setting the type to the column.

 EntityFrameworkExtras/UserDefinedTableGenerator.cs |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/EntityFrameworkExtras/UserDefinedTableGenerator.cs b/EntityFrameworkExtras/UserDefinedTableGenerator.cs
index ea62e55..c5b01a3 100644
--- a/EntityFrameworkExtras/UserDefinedTableGenerator.cs
+++ b/EntityFrameworkExtras/UserDefinedTableGenerator.cs
@@ -40,7 +40,13 @@ namespace EntityFrameworkExtras
         {
             foreach (string columnName in columns)
             {
-                dt.Columns.Add(columnName);
+                Type type = _type.GetProperty(columnName).PropertyType;
+                if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof (Nullable<>))
+                {
+                    type = type.GetGenericArguments()[0];
+                }
+                dt.Columns.Add(columnName, type);
+                    
             }
         }
Fodsuk commented 10 years ago

Hi Dimeptr,

Thanks for your recent points about bugs in the project. I'll get onto to looking at these in the next few days.

Mike

Fodsuk commented 10 years ago

fix committed to code