2009-06-12 Bill Holmes <billholmes54@gmail.com>
[mono.git] / mcs / class / System.Data.Linq / src / DbLinq.Oracle / OracleVendor.cs
1 #region MIT license\r
2 // \r
3 // MIT license\r
4 //\r
5 // Copyright (c) 2007-2008 Jiri Moudry, Pascal Craponne\r
6 // \r
7 // Permission is hereby granted, free of charge, to any person obtaining a copy\r
8 // of this software and associated documentation files (the "Software"), to deal\r
9 // in the Software without restriction, including without limitation the rights\r
10 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r
11 // copies of the Software, and to permit persons to whom the Software is\r
12 // furnished to do so, subject to the following conditions:\r
13 // \r
14 // The above copyright notice and this permission notice shall be included in\r
15 // all copies or substantial portions of the Software.\r
16 // \r
17 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
18 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
19 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
20 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
21 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
22 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
23 // THE SOFTWARE.\r
24 // \r
25 #endregion\r
26 using System;\r
27 using System.Data;\r
28 using System.Reflection;\r
29 using System.Collections.Generic;\r
30 using System.Text;\r
31 using System.Data.Linq;\r
32 using System.Data.Linq.Mapping;\r
33 #if MONO_STRICT\r
34 using System.Data.Linq.SqlClient;\r
35 #else\r
36 using DbLinq.Data.Linq.SqlClient;\r
37 #endif\r
38 using DbLinq.Vendor;\r
39 #if MONO_STRICT\r
40 using DataContext = System.Data.Linq.DataContext;\r
41 #else\r
42 using DataContext = DbLinq.Data.Linq.DataContext;\r
43 #endif\r
44 \r
45 namespace DbLinq.Oracle\r
46 {\r
47     [Vendor(typeof(OracleProvider))]\r
48 #if MONO_STRICT\r
49     internal\r
50 #else\r
51     public\r
52 #endif\r
53  class OracleVendor : Vendor.Implementation.Vendor\r
54     {\r
55         public override string VendorName { get { return "Oracle"; } }\r
56 \r
57         protected readonly OracleSqlProvider sqlProvider = new OracleSqlProvider();\r
58         public override ISqlProvider SqlProvider { get { return sqlProvider; } }\r
59 \r
60         public override bool Ping(DataContext dataContext)\r
61         {\r
62             return dataContext.ExecuteCommand("SELECT 11 FROM DUAL") == 11;\r
63         }\r
64 \r
65         public override IExecuteResult ExecuteMethodCall(DataContext context, MethodInfo method\r
66                                                                  , params object[] inputValues)\r
67         {\r
68             throw new NotImplementedException();\r
69         }\r
70 \r
71         // This method workds much better on various environment. But why? Thanks Oracle guys for dry documentation.\r
72         public override string BuildConnectionString(string host, string databaseName, string userName, string password)\r
73         {\r
74             var connectionStringBuilder = new StringBuilder();\r
75             connectionStringBuilder.AppendFormat(\r
76                 "Data Source = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = {0})(PORT = 1521)))(CONNECT_DATA = (SERVER = DEDICATED)))",\r
77                 host);\r
78             if (!string.IsNullOrEmpty(userName))\r
79             {\r
80                 connectionStringBuilder.AppendFormat("; User Id = {0}", userName);\r
81                 if (!string.IsNullOrEmpty(password))\r
82                     connectionStringBuilder.AppendFormat("; Password = {0}", password);\r
83             }\r
84             return connectionStringBuilder.ToString();\r
85         }\r
86 \r
87         protected override string ConnectionStringDatabase { get { return null; } }\r
88         protected override string ConnectionStringServer { get { return "data source"; } }\r
89     }\r
90 }\r