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