Tuesday 15 April 2014

oracle - Dapper and OrmLite IDBConnectionFactory in ServiceStack -


I'm impressed with the speed that I can build services using the service stack, but I can not understand for a while I am in the process of using the combination of aeramilite and dapper in my project, I am entering an IDbConnectionFactory like this in my Global.asax.cs. Configure Public Override Zero (Funq.Container Container) {var dbConnectionFactory = New OrmLiteConnectionFactory (ConfigUtils.GetConnectionString ("test"), true, Oracle DeAlex. Provider); Container.Register & lt; IDbConnectionFactory & gt; (DbConnectionFactory); Container. Registrar & lt; ISubscriberRepository & gt; (C = & gt; New Subscriber Repository (c.Resolve & lt; IDbConnectionFactory & gt; ()); }

This works fine for OrmLite but it is not as simple for Dapper. I am thinking that it should be more convenient than it really is. In my repository I am trying to call the Oracle stored procedure. This is my main reason to use Dapar and not OrmLite for this process. This is my repository:

  Public Category Subscriber Repository: ISubscriberRepository {IDBConnectionFactory conn} {_Conn = conn; } Public IDbConnectionFactory _conn {get; Set; } Public Subscriber Response GetSubscriber (SubscriberRequest Request) {Use (IDB Connection DB = _Conn.OpenDbConnection ()) {var resp = New Member Response (); & Lt; Subscriber & gt; S = db.Select & lt; Subscriber & gt; (Q = & gt; q.Subscribernum == Request Subscriberum & amp; amp; Prof. Personcode == Request. Personcode & amp; amp; q.Clientcode == Request.Clientcode); Resp.subscriber = s [0]; Return resp; }} Public Subscriber SearchSubscribers (member requests) {var response = new member response (); (Var cnn = new oracle connection ("this is my symbolic string")) {cnn.Open (); Var p = new OracleDynamicParameters (); P.Add ("@username", "unm", oracleadi type. P.Add ("@ Subscribernum", "", OracleDbType.Varchar2); P.Add ("@ Individual", "", Oracledi Type V. Verchar 2); P. Add ("Last name", "Test", Oracledi type. Worm 2); P.Add ("@FirstName", "AA", OraclediTypeVircCar 2); P. Add ("@ MI", "", Oracleadi Type. WB2); P. Add ("@dub", blank, oraclebtype.det); P.Add ("@ MaxResults", 200, OracleDbType.Int32); P. Add ("@cars", db type: oracledi type, reef cusor, direction: parameter direction. Output); (Use the SqlMapper.GridReader multi = cnn.QueryMultiple ("SEARCHSUBSCRIBER", P, Command: CommandType.StordProcedier)) (List & lt; SearchSubscriberResults & gt; R = Read more & lt; SearchSearch results & gt; ). ToList (); Response = R;}} Returning response;}}   

This works, but in reality this IDBCNACXTenter is not being used at all in the Search ServicesCheck function I have the connection string in my repository I do not want to eat, because I can really put myself in service.

I tried to use the service stack. Razor Daper. SQLMapper.QueryMultiple () but it does not work Because I can not map anything to Oracle sys_refcursor with no solution.

So, my question is, can I make a connection to the dipper from the IDBCConnection Factory? < P> Thank you! I am in OrCL (.NET) Does not have access to Oracle (not the days of my Perl), but using the Oracle connection. Interface IDbConnection.

You should be able to capture the JDb connection by yourself:

  IDB connection db = _conn.OpenDbConnection ()   

and Enter it for OracleConnection (assuming)

  var cnn = db in the form of Oracle connection;   

... then you can try calling Oracle-specific stuff like OracleDynamicParameters.

You may have to set it in AppHost.Configure () or elsewhere:

  OrmLiteConfig.DialateProvider = New OracleOrmLiteDialectProvider ();    

No comments:

Post a Comment