PageRenderTime 47ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/mcs/class/referencesource/System.Data.Linq/Provider/IProvider.cs

http://github.com/mono/mono
C# | 238 lines | 75 code | 18 blank | 145 comment | 0 complexity | e699d8cd1feb426c00e083599cfbff90 MD5 | raw file
Possible License(s): GPL-2.0, CC-BY-SA-3.0, LGPL-2.0, MPL-2.0-no-copyleft-exception, LGPL-2.1, Unlicense, Apache-2.0
  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;
  14. namespace System.Data.Linq.Provider {
  15. /// <summary>
  16. /// A data provider implements this interface to hook into the LINQ to SQL framework.
  17. /// </summary>
  18. internal interface IProvider : IDisposable {
  19. /// <summary>
  20. /// Initializes the database provider with the data services object and connection.
  21. /// </summary>
  22. /// <param name="dataServices"></param>
  23. /// <param name="connection">A connection string, connection object or transaction object
  24. /// used to seed the provider with database connection information.</param>
  25. void Initialize(IDataServices dataServices, object connection);
  26. /// <summary>
  27. /// The text writer used by the provider to output information such as query and commands
  28. /// being executed.
  29. /// </summary>
  30. TextWriter Log { get; set; }
  31. /// <summary>
  32. /// The connection object used by the provider when executing queries and commands.
  33. /// </summary>
  34. DbConnection Connection { get; }
  35. /// <summary>
  36. /// The transaction object used by the provider when executing queries and commands.
  37. /// </summary>
  38. DbTransaction Transaction { get; set; }
  39. /// <summary>
  40. /// The command timeout setting to use for command execution.
  41. /// </summary>
  42. int CommandTimeout { get; set; }
  43. /// <summary>
  44. /// Clears the connection of any current activity.
  45. /// </summary>
  46. void ClearConnection();
  47. /// <summary>
  48. /// Creates a new database instance (catalog or file) at the location specified by the connection
  49. /// using the metadata encoded within the entities or mapping file.
  50. /// </summary>
  51. void CreateDatabase();
  52. /// <summary>
  53. /// Deletes the database instance at the location specified by the connection.
  54. /// </summary>
  55. void DeleteDatabase();
  56. /// <summary>
  57. /// Returns true if the database specified by the connection object exists.
  58. /// </summary>
  59. /// <returns></returns>
  60. bool DatabaseExists();
  61. /// <summary>
  62. /// Executes the query specified as a LINQ expression tree.
  63. /// </summary>
  64. /// <param name="query"></param>
  65. /// <returns>A result object from which you can obtain the return value and output parameters.</returns>
  66. IExecuteResult Execute(Expression query);
  67. /// <summary>
  68. /// Compiles the query specified as a LINQ expression tree.
  69. /// </summary>
  70. /// <param name="query"></param>
  71. /// <returns>A compiled query instance.</returns>
  72. ICompiledQuery Compile(Expression query);
  73. /// <summary>
  74. /// Translates a DbDataReader into a sequence of objects (entity or projection) by mapping
  75. /// columns of the data reader to object members by name.
  76. /// </summary>
  77. /// <param name="elementType">The type of the resulting objects.</param>
  78. /// <param name="reader"></param>
  79. /// <returns></returns>
  80. IEnumerable Translate(Type elementType, DbDataReader reader);
  81. /// <summary>
  82. /// Translates an IDataReader containing multiple result sets into sequences of objects
  83. /// (entity or projection) by mapping columns of the data reader to object members by name.
  84. /// </summary>
  85. /// <param name="reader"></param>
  86. /// <returns></returns>
  87. IMultipleResults Translate(DbDataReader reader);
  88. /// <summary>
  89. /// Returns the query text in the database server's native query language
  90. /// that would need to be executed to perform the specified query.
  91. /// </summary>
  92. /// <param name="query">The query</param>
  93. /// <returns></returns>
  94. string GetQueryText(Expression query);
  95. /// <summary>
  96. /// Return an IDbCommand object representing the translation of specified query.
  97. /// </summary>
  98. /// <param name="query"></param>
  99. /// <returns></returns>
  100. DbCommand GetCommand(Expression query);
  101. }
  102. /// <summary>
  103. /// A compiled query.
  104. /// </summary>
  105. internal interface ICompiledQuery {
  106. /// <summary>
  107. /// Executes the compiled query using the specified provider and a set of arguments.
  108. /// </summary>
  109. /// <param name="provider">The provider that will execute the compiled query.</param>
  110. /// <param name="arguments">Argument values to supply to the parameters of the compiled query,
  111. /// when the query is specified as a LambdaExpression.</param>
  112. /// <returns></returns>
  113. IExecuteResult Execute(IProvider provider, object[] arguments);
  114. }
  115. internal static class DataManipulation {
  116. /// <summary>
  117. /// The method signature used to encode an Insert command.
  118. /// The method will throw a NotImplementedException if called directly.
  119. /// </summary>
  120. /// <typeparam name="TEntity"></typeparam>
  121. /// <typeparam name="TResult"></typeparam>
  122. /// <param name="item"></param>
  123. /// <param name="resultSelector"></param>
  124. /// <returns></returns>
  125. [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "item", Justification = "Microsoft: The method is being used to represent a method signature")]
  126. [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "resultSelector", Justification = "Microsoft: The method is being used to represent a method signature")]
  127. public static TResult Insert<TEntity, TResult>(TEntity item, Func<TEntity, TResult> resultSelector) {
  128. throw new NotImplementedException();
  129. }
  130. /// <summary>
  131. /// The method signature used to encode an Insert command.
  132. /// The method will throw a NotImplementedException if called directly.
  133. /// </summary>
  134. /// <typeparam name="TEntity"></typeparam>
  135. /// <param name="item"></param>
  136. /// <returns></returns>
  137. [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "item", Justification = "Microsoft: The method is being used to represent a method signature")]
  138. public static int Insert<TEntity>(TEntity item) {
  139. throw new NotImplementedException();
  140. }
  141. /// <summary>
  142. /// The method signature used to encode an Update command.
  143. /// The method will throw a NotImplementedException if called directly.
  144. /// </summary>
  145. /// <typeparam name="TEntity"></typeparam>
  146. /// <typeparam name="TResult"></typeparam>
  147. /// <param name="item"></param>
  148. /// <param name="check"></param>
  149. /// <param name="resultSelector"></param>
  150. /// <returns></returns>
  151. [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "item", Justification = "Microsoft: The method is being used to represent a method signature")]
  152. [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "check", Justification = "Microsoft: The method is being used to represent a method signature")]
  153. [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "resultSelector", Justification = "Microsoft: The method is being used to represent a method signature")]
  154. public static TResult Update<TEntity, TResult>(TEntity item, Func<TEntity, bool> check, Func<TEntity, TResult> resultSelector) {
  155. throw new NotImplementedException();
  156. }
  157. /// <summary>
  158. /// The method signature used to encode an Update command.
  159. /// The method will throw a NotImplementedException if called directly.
  160. /// </summary>
  161. /// <typeparam name="TEntity"></typeparam>
  162. /// <typeparam name="TResult"></typeparam>
  163. /// <param name="item"></param>
  164. /// <param name="resultSelector"></param>
  165. /// <returns></returns>
  166. [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "item", Justification = "Microsoft: The method is being used to represent a method signature")]
  167. [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "resultSelector", Justification = "Microsoft: The method is being used to represent a method signature")]
  168. public static TResult Update<TEntity, TResult>(TEntity item, Func<TEntity, TResult> resultSelector) {
  169. throw new NotImplementedException();
  170. }
  171. /// <summary>
  172. /// The method signature used to encode an Update command.
  173. /// The method will throw a NotImplementedException if called directly.
  174. /// </summary>
  175. /// <typeparam name="TEntity"></typeparam>
  176. /// <param name="item"></param>
  177. /// <param name="check"></param>
  178. /// <returns></returns>
  179. [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "item", Justification = "Microsoft: The method is being used to represent a method signature")]
  180. [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "check", Justification = "Microsoft: The method is being used to represent a method signature")]
  181. public static int Update<TEntity>(TEntity item, Func<TEntity, bool> check) {
  182. throw new NotImplementedException();
  183. }
  184. /// <summary>
  185. /// The method signature used to encode an Update command.
  186. /// The method will throw a NotImplementedException if called directly.
  187. /// </summary>
  188. /// <typeparam name="TEntity"></typeparam>
  189. /// <param name="item"></param>
  190. /// <returns></returns>
  191. [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "item", Justification = "Microsoft: The method is being used to represent a method signature")]
  192. public static int Update<TEntity>(TEntity item) {
  193. throw new NotImplementedException();
  194. }
  195. /// <summary>
  196. /// The method signature used to encode a Delete command.
  197. /// The method will throw a NotImplementedException if called directly.
  198. /// </summary>
  199. /// <typeparam name="TEntity"></typeparam>
  200. /// <param name="item"></param>
  201. /// <param name="check"></param>
  202. /// <returns></returns>
  203. [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "item", Justification = "Microsoft: The method is being used to represent a method signature")]
  204. [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "check", Justification = "Microsoft: The method is being used to represent a method signature")]
  205. public static int Delete<TEntity>(TEntity item, Func<TEntity, bool> check) {
  206. throw new NotImplementedException();
  207. }
  208. /// <summary>
  209. /// The method signature used to encode a Delete command.
  210. /// The method will throw a NotImplementedException if called directly.
  211. /// </summary>
  212. /// <typeparam name="TEntity"></typeparam>
  213. /// <param name="item"></param>
  214. /// <returns></returns>
  215. [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "item", Justification = "Microsoft: The method is being used to represent a method signature")]
  216. public static int Delete<TEntity>(TEntity item) {
  217. throw new NotImplementedException();
  218. }
  219. }
  220. }