Updates referencesource to .NET 4.7
[mono-project.git] / mcs / class / referencesource / System.Data.Linq / Provider / IProvider.cs
blob98438415b0c9a01915d459d7546e015af13d421f
1 using System;
2 using System.Collections;
3 using System.Collections.Generic;
4 using System.Data;
5 using System.Data.Linq;
6 using System.Data.Common;
7 using System.Linq.Expressions;
8 using System.IO;
9 using System.Linq;
10 using System.Text;
11 using System.Transactions;
12 using System.Reflection;
13 using System.Diagnostics.CodeAnalysis;
15 namespace System.Data.Linq.Provider {
17 /// <summary>
18 /// A data provider implements this interface to hook into the LINQ to SQL framework.
19 /// </summary>
20 internal interface IProvider : IDisposable {
21 /// <summary>
22 /// Initializes the database provider with the data services object and connection.
23 /// </summary>
24 /// <param name="dataServices"></param>
25 /// <param name="connection">A connection string, connection object or transaction object
26 /// used to seed the provider with database connection information.</param>
27 void Initialize(IDataServices dataServices, object connection);
29 /// <summary>
30 /// The text writer used by the provider to output information such as query and commands
31 /// being executed.
32 /// </summary>
33 TextWriter Log { get; set; }
35 /// <summary>
36 /// The connection object used by the provider when executing queries and commands.
37 /// </summary>
38 DbConnection Connection { get; }
40 /// <summary>
41 /// The transaction object used by the provider when executing queries and commands.
42 /// </summary>
43 DbTransaction Transaction { get; set; }
45 /// <summary>
46 /// The command timeout setting to use for command execution.
47 /// </summary>
48 int CommandTimeout { get; set; }
50 /// <summary>
51 /// Clears the connection of any current activity.
52 /// </summary>
53 void ClearConnection();
55 /// <summary>
56 /// Creates a new database instance (catalog or file) at the location specified by the connection
57 /// using the metadata encoded within the entities or mapping file.
58 /// </summary>
59 void CreateDatabase();
61 /// <summary>
62 /// Deletes the database instance at the location specified by the connection.
63 /// </summary>
64 void DeleteDatabase();
66 /// <summary>
67 /// Returns true if the database specified by the connection object exists.
68 /// </summary>
69 /// <returns></returns>
70 bool DatabaseExists();
72 /// <summary>
73 /// Executes the query specified as a LINQ expression tree.
74 /// </summary>
75 /// <param name="query"></param>
76 /// <returns>A result object from which you can obtain the return value and output parameters.</returns>
77 IExecuteResult Execute(Expression query);
79 /// <summary>
80 /// Compiles the query specified as a LINQ expression tree.
81 /// </summary>
82 /// <param name="query"></param>
83 /// <returns>A compiled query instance.</returns>
84 ICompiledQuery Compile(Expression query);
86 /// <summary>
87 /// Translates a DbDataReader into a sequence of objects (entity or projection) by mapping
88 /// columns of the data reader to object members by name.
89 /// </summary>
90 /// <param name="elementType">The type of the resulting objects.</param>
91 /// <param name="reader"></param>
92 /// <returns></returns>
93 IEnumerable Translate(Type elementType, DbDataReader reader);
95 /// <summary>
96 /// Translates an IDataReader containing multiple result sets into sequences of objects
97 /// (entity or projection) by mapping columns of the data reader to object members by name.
98 /// </summary>
99 /// <param name="reader"></param>
100 /// <returns></returns>
101 IMultipleResults Translate(DbDataReader reader);
103 /// <summary>
104 /// Returns the query text in the database server's native query language
105 /// that would need to be executed to perform the specified query.
106 /// </summary>
107 /// <param name="query">The query</param>
108 /// <returns></returns>
109 string GetQueryText(Expression query);
111 /// <summary>
112 /// Return an IDbCommand object representing the translation of specified query.
113 /// </summary>
114 /// <param name="query"></param>
115 /// <returns></returns>
116 DbCommand GetCommand(Expression query);
119 /// <summary>
120 /// A compiled query.
121 /// </summary>
122 internal interface ICompiledQuery {
123 /// <summary>
124 /// Executes the compiled query using the specified provider and a set of arguments.
125 /// </summary>
126 /// <param name="provider">The provider that will execute the compiled query.</param>
127 /// <param name="arguments">Argument values to supply to the parameters of the compiled query,
128 /// when the query is specified as a LambdaExpression.</param>
129 /// <returns></returns>
130 IExecuteResult Execute(IProvider provider, object[] arguments);
133 internal static class DataManipulation {
134 /// <summary>
135 /// The method signature used to encode an Insert command.
136 /// The method will throw a NotImplementedException if called directly.
137 /// </summary>
138 /// <typeparam name="TEntity"></typeparam>
139 /// <typeparam name="TResult"></typeparam>
140 /// <param name="item"></param>
141 /// <param name="resultSelector"></param>
142 /// <returns></returns>
143 [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "item", Justification = "Microsoft: The method is being used to represent a method signature")]
144 [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "resultSelector", Justification = "Microsoft: The method is being used to represent a method signature")]
145 public static TResult Insert<TEntity, TResult>(TEntity item, Func<TEntity, TResult> resultSelector) {
146 throw new NotImplementedException();
148 /// <summary>
149 /// The method signature used to encode an Insert command.
150 /// The method will throw a NotImplementedException if called directly.
151 /// </summary>
152 /// <typeparam name="TEntity"></typeparam>
153 /// <param name="item"></param>
154 /// <returns></returns>
155 [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "item", Justification = "Microsoft: The method is being used to represent a method signature")]
156 public static int Insert<TEntity>(TEntity item) {
157 throw new NotImplementedException();
159 /// <summary>
160 /// The method signature used to encode an Update command.
161 /// The method will throw a NotImplementedException if called directly.
162 /// </summary>
163 /// <typeparam name="TEntity"></typeparam>
164 /// <typeparam name="TResult"></typeparam>
165 /// <param name="item"></param>
166 /// <param name="check"></param>
167 /// <param name="resultSelector"></param>
168 /// <returns></returns>
169 [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "item", Justification = "Microsoft: The method is being used to represent a method signature")]
170 [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "check", Justification = "Microsoft: The method is being used to represent a method signature")]
171 [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "resultSelector", Justification = "Microsoft: The method is being used to represent a method signature")]
172 public static TResult Update<TEntity, TResult>(TEntity item, Func<TEntity, bool> check, Func<TEntity, TResult> resultSelector) {
173 throw new NotImplementedException();
175 /// <summary>
176 /// The method signature used to encode an Update command.
177 /// The method will throw a NotImplementedException if called directly.
178 /// </summary>
179 /// <typeparam name="TEntity"></typeparam>
180 /// <typeparam name="TResult"></typeparam>
181 /// <param name="item"></param>
182 /// <param name="resultSelector"></param>
183 /// <returns></returns>
184 [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "item", Justification = "Microsoft: The method is being used to represent a method signature")]
185 [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "resultSelector", Justification = "Microsoft: The method is being used to represent a method signature")]
186 public static TResult Update<TEntity, TResult>(TEntity item, Func<TEntity, TResult> resultSelector) {
187 throw new NotImplementedException();
189 /// <summary>
190 /// The method signature used to encode an Update command.
191 /// The method will throw a NotImplementedException if called directly.
192 /// </summary>
193 /// <typeparam name="TEntity"></typeparam>
194 /// <param name="item"></param>
195 /// <param name="check"></param>
196 /// <returns></returns>
197 [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "item", Justification = "Microsoft: The method is being used to represent a method signature")]
198 [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "check", Justification = "Microsoft: The method is being used to represent a method signature")]
199 public static int Update<TEntity>(TEntity item, Func<TEntity, bool> check) {
200 throw new NotImplementedException();
202 /// <summary>
203 /// The method signature used to encode an Update command.
204 /// The method will throw a NotImplementedException if called directly.
205 /// </summary>
206 /// <typeparam name="TEntity"></typeparam>
207 /// <param name="item"></param>
208 /// <returns></returns>
209 [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "item", Justification = "Microsoft: The method is being used to represent a method signature")]
210 public static int Update<TEntity>(TEntity item) {
211 throw new NotImplementedException();
213 /// <summary>
214 /// The method signature used to encode a Delete command.
215 /// The method will throw a NotImplementedException if called directly.
216 /// </summary>
217 /// <typeparam name="TEntity"></typeparam>
218 /// <param name="item"></param>
219 /// <param name="check"></param>
220 /// <returns></returns>
221 [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "item", Justification = "Microsoft: The method is being used to represent a method signature")]
222 [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "check", Justification = "Microsoft: The method is being used to represent a method signature")]
223 public static int Delete<TEntity>(TEntity item, Func<TEntity, bool> check) {
224 throw new NotImplementedException();
226 /// <summary>
227 /// The method signature used to encode a Delete command.
228 /// The method will throw a NotImplementedException if called directly.
229 /// </summary>
230 /// <typeparam name="TEntity"></typeparam>
231 /// <param name="item"></param>
232 /// <returns></returns>
233 [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "item", Justification = "Microsoft: The method is being used to represent a method signature")]
234 public static int Delete<TEntity>(TEntity item) {
235 throw new NotImplementedException();