2 using System
.Collections
;
3 using System
.Collections
.Generic
;
5 using System
.Data
.Linq
;
6 using System
.Data
.Common
;
7 using System
.Linq
.Expressions
;
11 using System
.Transactions
;
12 using System
.Reflection
;
13 using System
.Diagnostics
.CodeAnalysis
;
15 namespace System
.Data
.Linq
.Provider
{
18 /// A data provider implements this interface to hook into the LINQ to SQL framework.
20 internal interface IProvider
: IDisposable
{
22 /// Initializes the database provider with the data services object and connection.
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
);
30 /// The text writer used by the provider to output information such as query and commands
33 TextWriter Log { get; set; }
36 /// The connection object used by the provider when executing queries and commands.
38 DbConnection Connection { get; }
41 /// The transaction object used by the provider when executing queries and commands.
43 DbTransaction Transaction { get; set; }
46 /// The command timeout setting to use for command execution.
48 int CommandTimeout { get; set; }
51 /// Clears the connection of any current activity.
53 void ClearConnection();
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.
59 void CreateDatabase();
62 /// Deletes the database instance at the location specified by the connection.
64 void DeleteDatabase();
67 /// Returns true if the database specified by the connection object exists.
69 /// <returns></returns>
70 bool DatabaseExists();
73 /// Executes the query specified as a LINQ expression tree.
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
);
80 /// Compiles the query specified as a LINQ expression tree.
82 /// <param name="query"></param>
83 /// <returns>A compiled query instance.</returns>
84 ICompiledQuery
Compile(Expression query
);
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.
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
);
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.
99 /// <param name="reader"></param>
100 /// <returns></returns>
101 IMultipleResults
Translate(DbDataReader reader
);
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.
107 /// <param name="query">The query</param>
108 /// <returns></returns>
109 string GetQueryText(Expression query
);
112 /// Return an IDbCommand object representing the translation of specified query.
114 /// <param name="query"></param>
115 /// <returns></returns>
116 DbCommand
GetCommand(Expression query
);
120 /// A compiled query.
122 internal interface ICompiledQuery
{
124 /// Executes the compiled query using the specified provider and a set of arguments.
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
{
135 /// The method signature used to encode an Insert command.
136 /// The method will throw a NotImplementedException if called directly.
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();
149 /// The method signature used to encode an Insert command.
150 /// The method will throw a NotImplementedException if called directly.
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();
160 /// The method signature used to encode an Update command.
161 /// The method will throw a NotImplementedException if called directly.
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();
176 /// The method signature used to encode an Update command.
177 /// The method will throw a NotImplementedException if called directly.
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();
190 /// The method signature used to encode an Update command.
191 /// The method will throw a NotImplementedException if called directly.
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();
203 /// The method signature used to encode an Update command.
204 /// The method will throw a NotImplementedException if called directly.
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();
214 /// The method signature used to encode a Delete command.
215 /// The method will throw a NotImplementedException if called directly.
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();
227 /// The method signature used to encode a Delete command.
228 /// The method will throw a NotImplementedException if called directly.
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();