Add new reference to the generated DBSpecific LLBL project is advisable?

Posts   
 
    
Gabor
User
Posts: 97
Joined: 29-Jan-2005
# Posted on: 30-Jun-2005 13:27:29   

Hi Frans,

My problem is, that I want to use custom connection string, that I add to the DataAccessAdapter in the constructor.

I Created a New Globals project, that creates this connection string from the config file's keys, and this project is referenced from the BLL project - the only project that communicates with the LLBL db specific project.

My problem is, that I have custom entity validators, some of them requires the same connection string.

If I put the reference to my Globals project, from within db specific LLBL project, doesn't it breaks the compatibility with the LLBLGenerator, or later versions?

Is it advisable solution, or you can me propose some more apprapriate one?

I want to use custom constring for security reason.

Thanks in advance

Gabor

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 01-Jul-2005 10:36:06   

I think you don't need a reference to the globals project in the DBSpecific project. In your BLL project, you reference the DBSpecific project, correct? So you can there create a factory for DataAccessAdapter objects. (simple class, just creates a DataAccessAdapter instance and passes the Globals.ConnectionString to the constructor).

In the .config file, simply make sure that there's not a Main.Connectionstring key / value pair in appSettings, so code which calls the DataAccessAdapter directly can't work, as it can't read a connection string.

Would that work in your situation?

Frans Bouma | Lead developer LLBLGen Pro
Gabor
User
Posts: 97
Joined: 29-Jan-2005
# Posted on: 02-Jul-2005 02:55:41   

Thanks Frans,

I wrote DBSpecific instead of DBGeneric rage

In My situation, I have entityValidators, in some of them I have to get some information from the database.

The validators reside in the DBGeneric project, and I can't send to validator nothing as parameter.

If I want to use the connection string to initialize the DataAccessAdapter, from where to take them except from my own globals project, that would requires a reference to it from the DBGeneric project. Isn't it?

Do You know a better solution?

Thanks in advance

Gabor

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 02-Jul-2005 10:43:04   

Gabor wrote:

Thanks Frans,

I wrote DBSpecific instead of DBGeneric rage

In My situation, I have entityValidators, in some of them I have to get some information from the database.

The validators reside in the DBGeneric project, and I can't send to validator nothing as parameter.

You can program these using the interface IDataAccessAdapter, instead of using the 'DataAccessAdapter' class. That way, you can pass in a DataAccessAdapter instance at runtime, though you don't need to reference the DBSpecific vs.net project from the DBGeneric project, as the IDataAccessAdapter interface is in the ORMSupport classes simple_smile

If I want to use the connection string to initialize the DataAccessAdapter, from where to take them except from my own globals project, that would requires a reference to it from the DBGeneric project. Isn't it?

Do You know a better solution?

SOMEWHERE the DataAccessAdapter instances have to be created. When you call adapter.SaveEntity(someEntity);, the adapter instance is created in some code, can't you there also pass it to the validators? That code which creates the adapters will then retrieve one from the globals project, so the dbgeneric code doesn't have to know anything about the dbspecific code nor about the globals project.

Frans Bouma | Lead developer LLBLGen Pro