install nopcommerce with oracle -
hello downloaded solution nopcommerce e-commerce open source achievement operate , install without problems mssqlserver database implement oracledatabase
official site http://www.nopcommerce.com/
i have been guiding me post http://www.nopcommerce.com/boards/t/17712/mysql-support.aspx
i have tried follow steps indicated mysql , adapt oracle yet 1 of first things tells me creation of 2 classes
oracleconnectionfactory:
using system; using system.collections.generic; using system.linq; using system.text; using system.data.entity.infrastructure; using system.data.common; using oracle.dataaccess.client; namespace nop.data { public class oracleconnectionfactory : idbconnectionfactory { private readonly string _baseconnectionstring; private func<string, dbproviderfactory> _providerfactorycreator; public oracleconnectionfactory() { } public oracleconnectionfactory(string baseconnectionstring) { this._baseconnectionstring = baseconnectionstring; } public dbconnection createconnection(string nameorconnectionstring) { string connectionstring = nameorconnectionstring; bool treatasconnectionstring = nameorconnectionstring.indexof('=') >= 0; if (!treatasconnectionstring) { oracleconnectionstringbuilder builder = new oracleconnectionstringbuilder(this.baseconnectionstring); //mysqlconnectionstringbuilder builder = new mysqlconnectionstringbuilder(this.baseconnectionstring); //builder.server = nameorconnectionstring; connectionstring = builder.connectionstring; } dbconnection connection = null; try { connection = this.providerfactory("oracle.dataaccess.client").createconnection(); connection.connectionstring = connectionstring; } catch { //connection = new mysqlconnection(connectionstring); connection = new oracleconnection(connectionstring); } return connection; } public string baseconnectionstring { { return this._baseconnectionstring; } } internal func<string, dbproviderfactory> providerfactory { { func<string, dbproviderfactory> func1 = this._providerfactorycreator; return delegate(string name) { return dbproviderfactories.getfactory(name); }; } set { this._providerfactorycreator = value; } } } }
oracleprovider :
using system; using system.collections.generic; using system.data.common; using system.data.entity; using system.data.entity.infrastructure; using system.data.sqlclient; using system.io; using system.text; using system.web.hosting; using nop.data.initializers; using oracle.dataaccess.client; using nop.core.data; namespace nop.data { public class oracledataprovider : idataprovider { #region utilities protected virtual string[] parsecommands(string filepath, bool throwexceptionifnonexists) { if (!file.exists(filepath)) { if (throwexceptionifnonexists) throw new argumentexception(string.format("specified file doesn't exist - {0}", filepath)); else return new string[0]; } var statements = new list<string>(); using (var stream = file.openread(filepath)) using (var reader = new streamreader(stream)) { var statement = ""; while ((statement = readnextstatementfromstream(reader)) != null) { statements.add(statement); } } return statements.toarray(); } protected virtual string readnextstatementfromstream(streamreader reader) { var sb = new stringbuilder(); string lineoftext; while (true) { lineoftext = reader.readline(); if (lineoftext == null) { if (sb.length > 0) return sb.tostring(); else return null; } //mysql doesn't support go, use commented out go separator if (lineoftext.trimend().toupper() == "-- go") break; sb.append(lineoftext + environment.newline); } return sb.tostring(); } #endregion #region methods public virtual void initconnectionfactory() { //var connectionfactory = new sqlconnectionfactory(); var connectionfactory = new oracleconnectionfactory(); //todo fix compilation warning (below) #pragma warning disable 0618 database.defaultconnectionfactory = connectionfactory; } /// <summary> /// initialize database /// </summary> public virtual void initdatabase() { initconnectionfactory(); setdatabaseinitializer(); } /// <summary> /// set database initializer /// </summary> public virtual void setdatabaseinitializer() { //pass table names ensure have nopcommerce 2.x installed var tablestovalidate = new[] { "customer", "discount", "order", "product", "shoppingcartitem" }; //custom commands (stored proedures, indexes) var customcommands = new list<string>(); //use webhelper.mappath instead of hostingenvironment.mappath not available in unit tests customcommands.addrange(parsecommands(hostingenvironment.mappath("~/app_data/install/sqlserver.indexes.sql"), false)); //use webhelper.mappath instead of hostingenvironment.mappath not available in unit tests customcommands.addrange(parsecommands(hostingenvironment.mappath("~/app_data/install/sqlserver.storedprocedures.sql"), false)); var initializer = new createtablesifnotexist<nopobjectcontext>(tablestovalidate, customcommands.toarray()); database.setinitializer(initializer); } /// <summary> /// value indicating whether data provider supports stored procedures /// </summary> public virtual bool storedproceduredsupported { { return true; } } /// <summary> /// gets support database parameter object (used stored procedures) /// </summary> /// <returns>parameter</returns> public virtual dbparameter getparameter() { //return new sqlparameter(); return new oracleparameter(); } #endregion } }
also installed managed nuget package link said http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/dotnet/codefirst/index.html
oracle odp.net managed driver
in nop.data , nop.web
i appreciate freshened steps need or may going
one of first thing trying oracle provider recognize , achieve connect database
it interesting question. using nop commerce oracle technically possible, wild ride you.
good news first. nop commerce architectured based on repository pattern. nop.data abstracts sql server related data access. need re-write entirely.
not news next. search, paging, catalog listing uses stored procedure in sql server. may need re-write completely. , of time, on own. unless if confident oracle , .net ef, wild ride.
i say, less problem if want stick sql server. understand sometime may not make technical decision. can explain complexity , effort needed migrate person makes decision.
source: nopcommerce developer last 2.5years.
Comments
Post a Comment