annotate Source/Data/DataProvider/SqlCeDataProvider.cs @ 3:1ef98bd70424

!bug 100 +3h Исправление проблемы BLToolkit + mono 3.4
author cin
date Fri, 22 Aug 2014 17:34:46 +0400
parents f990fcb411a9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
1 using System;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
2 using System.Data;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
3 using System.Data.Common;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
4
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
5 // System.Data.SqlServerCe.dll must be referenced.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
6 // http://www.microsoft.com/sql/editions/compact/default.mspx
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
7 //
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
8 using System.Data.SqlServerCe;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
9
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
10 namespace BLToolkit.Data.DataProvider
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
11 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
12 using Sql.SqlProvider;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
13
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
14 /// <summary>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
15 /// Implements access to the Data Provider for Microsoft SQL Server 2005 Everywhere Edition
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
16 /// </summary>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
17 /// <remarks>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
18 /// See the <see cref="DbManager.AddDataProvider(DataProviderBase)"/> method to find an example.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
19 /// </remarks>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
20 /// <seealso cref="DbManager.AddDataProvider(DataProviderBase)">AddDataManager Method</seealso>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
21 public sealed class SqlCeDataProvider: DataProviderBase
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
22 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
23 /// <summary>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
24 /// Creates the database connection object.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
25 /// </summary>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
26 /// <remarks>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
27 /// See the <see cref="DbManager.AddDataProvider(DataProviderBase)"/> method to find an example.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
28 /// </remarks>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
29 /// <seealso cref="DbManager.AddDataProvider(DataProviderBase)">AddDataManager Method</seealso>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
30 /// <returns>The database connection object.</returns>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
31 public override IDbConnection CreateConnectionObject()
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
32 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
33 return new SqlCeConnection();
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
34 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
35
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
36 /// <summary>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
37 /// Creates the data adapter object.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
38 /// </summary>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
39 /// <remarks>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
40 /// See the <see cref="DbManager.AddDataProvider(DataProviderBase)"/> method to find an example.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
41 /// </remarks>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
42 /// <seealso cref="DbManager.AddDataProvider(DataProviderBase)">AddDataManager Method</seealso>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
43 /// <returns>A data adapter object.</returns>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
44 public override DbDataAdapter CreateDataAdapterObject()
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
45 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
46 return new SqlCeDataAdapter();
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
47 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
48
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
49 /// <summary>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
50 /// Populates the specified IDbCommand object's Parameters collection with
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
51 /// parameter information for the stored procedure specified in the IDbCommand.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
52 /// </summary>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
53 /// <remarks>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
54 /// See the <see cref="DbManager.AddDataProvider(DataProviderBase)"/> method to find an example.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
55 /// </remarks>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
56 /// <seealso cref="DbManager.AddDataProvider(DataProviderBase)">AddDataManager Method</seealso>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
57 /// <param name="command">The IDbCommand referencing the stored procedure for which the parameter information is to be derived. The derived parameters will be populated into the Parameters of this command.</param>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
58 public override bool DeriveParameters(IDbCommand command)
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
59 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
60 // SqlCeCommandBuilder does not implement DeriveParameters.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
61 // This is not surprising, since SQL/e has no support for stored procs.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
62 //
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
63 return false;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
64 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
65
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
66 public override object Convert(object value, ConvertType convertType)
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
67 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
68 switch (convertType)
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
69 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
70 case ConvertType.ExceptionToErrorNumber:
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
71 if (value is SqlCeException)
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
72 return ((SqlCeException)value).NativeError;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
73 break;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
74 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
75
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
76 return SqlProvider.Convert(value, convertType);
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
77 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
78
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
79 /// <summary>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
80 /// Returns connection type.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
81 /// </summary>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
82 /// <remarks>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
83 /// See the <see cref="DbManager.AddDataProvider(DataProviderBase)"/> method to find an example.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
84 /// </remarks>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
85 /// <seealso cref="DbManager.AddDataProvider(DataProviderBase)">AddDataManager Method</seealso>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
86 /// <value>An instance of the <see cref="Type"/> class.</value>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
87 public override Type ConnectionType
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
88 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
89 get { return typeof(SqlCeConnection); }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
90 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
91
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
92 /// <summary>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
93 /// Returns the data provider name.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
94 /// </summary>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
95 /// <remarks>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
96 /// See the <see cref="DbManager.AddDataProvider(DataProviderBase)"/> method to find an example.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
97 /// </remarks>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
98 /// <seealso cref="DbManager.AddDataProvider(DataProviderBase)">AddDataProvider Method</seealso>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
99 /// <value>Data provider name.</value>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
100 public override string Name
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
101 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
102 get { return DataProvider.ProviderName.SqlCe; }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
103 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
104
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
105 public override int MaxBatchSize
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
106 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
107 get { return 0; }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
108 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
109
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
110 public override ISqlProvider CreateSqlProvider()
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
111 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
112 return new SqlCeSqlProvider();
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
113 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
114
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
115 public override DbType GetParameterDbType(DbType dbType)
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
116 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
117 return dbType == DbType.DateTime2 ? DbType.DateTime : dbType;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
118 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
119 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
120 }