ssteenkiste / nettiers

Automatically exported from code.google.com/p/nettiers
1 stars 0 forks source link

Wrong data type mapping for the new "time", "geography", "geometry" data types in SQL Server 2008 #199

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a simple SQL Server 2008 Database with one table which 
contains "time", "geography", and "geometry" columns and run NetTiers V2.3.
2.
3.

What is the expected output? What do you see instead?

DateTime should be used to map to "time" columns.
SqlGeography should be used to map to "geography" columns.
SqlGeometry should be used to map to "geometry" columns.

The created entities use "TimeSpan" to map to the "Time" column, 
and "Object" to map to both "Geography" and "Geometry" columns.

Also, as discussed with CodeSmith team, the CSMAP files are not referenced 
at all during the process which shouldn't be the case.

What version of .netTiers and CodeSmith are you using?

NetTiers V2.3 official release
CodeSmith V5.0.5 official release

Please provide any additional information below.

Modified DbType-CSharp.csmap as suggested by CodeSmith team but that did 
not make any difference.  Also tried to modify SqlNativeType-DbType.csmap 
and it won't work either.

Original issue reported on code.google.com by chienhon...@gmail.com on 17 Apr 2009 at 5:54

Attachments:

GoogleCodeExporter commented 9 years ago
"time" database type SHOULD map to TimeSpan, as per official docs: 
http://msdn.microsoft.com/en-us/library/bb675168.aspx

For Geography and Geometry, there is only "object" available in the .NET 
Framework. 
The types you refer to are included in Microsoft.SqlServer.Types, which is a 
separate install from here: http://www.microsoft.com/downloads/details.aspx?
FamilyId=C6C3E9EF-BA29-4A43-8D69-A2BED18FE73C&displaylang=en (Called Microsoft 
SQL 
Server System CLR Types) - more info here: http://msdn.microsoft.com/en-
us/library/ms131092.aspx

Original comment by ejls...@hotmail.com on 18 Apr 2009 at 9:03

GoogleCodeExporter commented 9 years ago
If "time" should be mapped to "TimeSpan", please just use the attached sql 
statement 
to generate a very simple single table SQL Server 2008 database and then try 
run 
NetTiers against it.  You will find quite a few errors and also the enenty 
generated 
will cause error and the error message is something about can not convert 
"TimeSpan" 
to "DateTime".  For example, entity.StartTime = stime;   In short, I don't 
think 
that official doc is correct.  I do understand that SqlGeography and 
SqlGeometry are 
out of Microsoft.SqlServer.Types which is (I believe) also a part of the .NET 
Framework 3.5 SP1 install.  These 2 are VERY VERY useful to deal with those 2 
new 
data types introduced in SQL Server 2008.  I don't really know how useful 
mapping 
those two data types to "object" can be for any GIS related applications 
utilizing 
those 2 new data types.

Original comment by chienhon...@gmail.com on 18 Apr 2009 at 6:59

GoogleCodeExporter commented 9 years ago
I filed this bug out of the discussion with CodeSmith team.  Please see below 
what 
CodeSmith team sent me after couple rounds of email exchange:

"Could you please log this as a bug on the .netTiers bug tracker
(http://code.google.com/p/nettiers/). I just talked to a team member and we are 
going to rewrite this code for creating the properties as it is in bad shape. 
It 
should be using a mapping file but isn't and updating the mapping file didn't 
fix 
the issue. You could manually update the following methods in the CommonSqlCode 
in 
the mean time (private string GetAliasName(string owner, string obj, string 
item, 
ReturnFields returnType, NameConversionType convertType))."

I hope this helps the NetTiers team to explore this issue.  Thx.

Original comment by chienhon...@gmail.com on 18 Apr 2009 at 7:03

GoogleCodeExporter commented 9 years ago

Original comment by bniemyjski on 25 May 2009 at 3:30

GoogleCodeExporter commented 9 years ago
Hello,

This is something that will be fixed in 3.0. It will use a mapping file and the 
user
will have to add the SQL2008 Types that map to Microsoft.SqlServer as we can't 
assume
the users have that out of the box.

Thanks
-Blake

Original comment by bniemyjski on 25 May 2009 at 4:08

GoogleCodeExporter commented 9 years ago
Would it be possible to include the Microsoft.SqlServer.Types assembly in the 
netTiers References folder?  This would solve the problem of missing assemblies 
at compile time if the geography/geometry types are used.

Original comment by livingst...@gmail.com on 10 Jun 2010 at 3:05

GoogleCodeExporter commented 9 years ago
Hello,

We could possibly do this, I'm not sure if there is anything to worry about 
with the licensing of this assembly. If you want to create a patch for this 
issue and include the assembly, I'll review it and commit it to core if 
everything checks out.

Thanks
-Blake Niemyjski

Original comment by bniemyjski on 10 Jun 2010 at 10:43

GoogleCodeExporter commented 9 years ago
I have committed a partial solution, r881 – DbType.Time initialised with new 
TimeSpan(1,0,0,0,0), and additional logic added to the input parameter builder 
for the INSERT & UPDATE methods to cater for the SqlDbType.Time.

Original comment by xk...@yahoo.com on 11 Feb 2011 at 2:09