Guest User

Untitled

a guest
Feb 10th, 2017
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.92 KB | None | 0 0
  1. using System.Configuration;
  2. using System.Data;
  3. using System.Data.OracleClient;
  4. using Ninject.Modules;
  5. using Ninject.Web.Common;
  6.  
  7. namespace ClassLibrary1
  8. {
  9.     public class Oracle
  10.     {
  11.         private readonly OracleConnection _connection;
  12.         private readonly OracleCommand _command;
  13.  
  14.         public Oracle(OracleConnection connection, OracleCommand command)
  15.         {
  16.             _connection = connection;
  17.             _command = command;
  18.         }
  19.  
  20.         public DataSet QueryExecuter(string query)
  21.         {
  22.             //...
  23.         }
  24.     }
  25.  
  26.     public class OracleModule : NinjectModule
  27.     {
  28.         public override void Load()
  29.         {
  30.             Bind<Oracle>()
  31.                 .To<Oracle>()
  32.                 .InRequestScope();
  33.  
  34.             Bind<OracleConnection>()
  35.                 .To<OracleConnection>()
  36.                 .InRequestScope()
  37.                 .WithConstructorArgument("connectionString", ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString);
  38.  
  39.             Bind<OracleCommand>()
  40.                 .To<OracleCommand>()
  41.                 .InRequestScope();
  42.         }
  43.     }
  44. }
Add Comment
Please, Sign In to add comment