Page 1 of 1

DevArt Entity Model, how to change nls_language on connect?

Posted: Fri 22 Oct 2010 07:59
by r.m.saddler
Hi,

I have a webserver that talks to multiple oracle databases. One of these databases has a different nls_language setting to the others so historically when we have communicated with it using .net we have had to issue an "EXECUTE IMMEDIATE ('ALTER SESSION SET NLS_LANGUAGE=american');" so that PLSQL operates correctly.

My latest project uses a Devart Entity Model with a LinqToEntitiesDomainService(Of TEntities) and I would like to know where I should run this command in code so that all calls subsequently made to the database operate as expected?

Many thanks,

Rob.

Posted: Fri 22 Oct 2010 11:59
by AndreyR
In case you are using Entity Framework v4, you can simply use the ExecuteStoreCommand method.
And anyway, you can get the store connection from the objectContextInstance.Connection property and then use it like in the following sample:

Code: Select all

var connection = ((EntityConnection)(objectContextInstance.Connection)).StoreConnection; 
connection.Open();
var command = connection.CreateCommand();
command.CommandText = "EXECUTE IMMEDIATE ('ALTER SESSION SET NLS_LANGUAGE=american')";
command.ExecuteNonQuery();
Put this code in the OnCreated method of your ObjectContext (don't forget the condition of the server name with different NLS_LANG settings).