Datei: Provider/SqlServerProvider/NDO.SqlServer/SqlServerGenerator.cs
Last Commit (2a2e7ba)
1 | using NDOInterfaces; |
2 | using System; |
3 | using System.Collections.Generic; |
4 | using System.Data; |
5 | using System.Text; |
6 | |
7 | namespace SqlServerProvider |
8 | { |
9 | ····public class SqlServerGenerator : AbstractSQLGenerator |
10 | ····{ |
11 | ········public SqlServerGenerator() |
12 | ········{ |
13 | ········} |
14 | |
15 | ········public override string ProviderName |
16 | ········{ |
17 | ············get { return "SqlServer"; } |
18 | ········} |
19 | |
20 | ········public override string DropTable( string tableName ) |
21 | ········{ |
22 | ············StringBuilder sb = new StringBuilder(); |
23 | ············sb.Append( "if exists (select * from sysobjects where id = object_id(N'" ); |
24 | ············sb.Append( tableName ); |
25 | ············sb.Append( "') and OBJECTPROPERTY(id, N'IsUserTable') = 1)\n" ); |
26 | ············sb.Append( "DROP TABLE " ); |
27 | ············sb.Append( tableName ); |
28 | ············sb.Append( ";\n" ); |
29 | ············return sb.ToString(); |
30 | ········} |
31 | |
32 | ········public override bool LengthAllowed( Type t ) |
33 | ········{ |
34 | ············return t == typeof( string ) || t == typeof( decimal ); |
35 | ········} |
36 | |
37 | ········public override bool LengthAllowed( string dbType ) |
38 | ········{ |
39 | ············return string.Compare( dbType, "nvarchar", true ) == 0 || string.Compare( dbType, "decimal", true ) == 0; |
40 | ········} |
41 | |
42 | ········public override string DbTypeFromType( Type t, int size ) |
43 | ········{ |
44 | ············if (t == typeof( DateTime )) |
45 | ················return "DateTime"; |
46 | ············return ((SqlDbType)Provider.GetDbType( t )).ToString(); |
47 | ········} |
48 | |
49 | public override string AutoIncrementColumn( string columnName, Type dataType, string columnType, string width ) |
50 | ········{ |
51 | ············return columnName + " " + columnType + " " + width + " IDENTITY (1, 1) "; |
52 | ········} |
53 | |
54 | |
55 | ········public override bool HasSpecialAutoIncrementColumnFormat |
56 | ········{ |
57 | ············get { return true; } |
58 | ········} |
59 | |
60 | |
61 | ········public override string AlterColumnType() |
62 | ········{ |
63 | ············return "ALTER COLUMN"; |
64 | ········} |
65 | ····} |
66 | } |
67 |
New Commit (1e68dc7)
1 | using NDOInterfaces; |
2 | using System; |
3 | using System.Collections.Generic; |
4 | using System.Data; |
5 | using System.Text; |
6 | |
7 | namespace SqlServerProvider |
8 | { |
9 | ····public class SqlServerGenerator : AbstractSQLGenerator |
10 | ····{ |
11 | ········public SqlServerGenerator() |
12 | ········{ |
13 | ········} |
14 | |
15 | ········public override string ProviderName |
16 | ········{ |
17 | ············get { return "SqlServer"; } |
18 | ········} |
19 | |
20 | ········public override string DropTable( string tableName ) |
21 | ········{ |
22 | ············StringBuilder sb = new StringBuilder(); |
23 | ············sb.Append( "if exists (select * from sysobjects where id = object_id(N'" ); |
24 | ············sb.Append( tableName ); |
25 | ············sb.Append( "') and OBJECTPROPERTY(id, N'IsUserTable') = 1)\n" ); |
26 | ············sb.Append( "DROP TABLE " ); |
27 | ············sb.Append( tableName ); |
28 | ············sb.Append( ";\n" ); |
29 | ············return sb.ToString(); |
30 | ········} |
31 | |
32 | ········public override bool LengthAllowed( Type t ) |
33 | ········{ |
34 | ············return t == typeof( string ) || t == typeof( decimal ); |
35 | ········} |
36 | |
37 | ········public override bool LengthAllowed( string dbType ) |
38 | ········{ |
39 | ············return string.Compare( dbType, "nvarchar", true ) == 0 || string.Compare( dbType, "decimal", true ) == 0; |
40 | ········} |
41 | |
42 | ········public override string DbTypeFromType( Type t, int size ) |
43 | ········{ |
44 | ············if (t == typeof( DateTime )) |
45 | ················return "DateTime"; |
46 | ············return ((SqlDbType)Provider.GetDbType( t )).ToString(); |
47 | ········} |
48 | |
49 | public override string AutoIncrementColumn( string columnName, Type dataType, string columnType, string width, bool isPrimary ) |
50 | ········{ |
51 | ············return columnName + " " + columnType + " " + width + " IDENTITY (1, 1) "; |
52 | ········} |
53 | |
54 | |
55 | ········public override bool HasSpecialAutoIncrementColumnFormat |
56 | ········{ |
57 | ············get { return true; } |
58 | ········} |
59 | |
60 | |
61 | ········public override string AlterColumnType() |
62 | ········{ |
63 | ············return "ALTER COLUMN"; |
64 | ········} |
65 | ····} |
66 | } |
67 |