DbUtils.CreateConnection

Posts   
 
    
alzchem
User
Posts: 2
Joined: 09-Sep-2015
# Posted on: 09-Sep-2015 14:31:00   

Sorry, but I can't find DbUtils.CreateConnection - equivalent in LLBLGEN Pro 4.2. Can you help me?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 09-Sep-2015 17:08:32   

Please see: http://www.llblgen.com/documentation/4.2/LLBLGen%20Pro%20RTF/hh_goto.htm#migratingcode.htm

It's a breaking change introduced in v3.0:

SelfServicing: DbUtils has been removed. The static settings and methods are moved to the DaoBase class. The Db specific methods for sqlserver, like SetArithAbortFlag and SetSqlserverCompatibilityLevel are moved to the new class CommonDaoBase, which is located in the DaoClasses namespace. As DbUtils' public properties are not used frequently in an application, breaking code is minimal: rename the call / reference to the DbUtils member to a call to the CommonDaoBase class method / property instead. The DbUtils.CreateTransaction(3) method has been removed (there's no replacement in CommonDaoBase). The reason is that 'name' is no longer used. Use the overload which don't accept a name. This method also has been moved to DaoBase / IDao and is now no longer static. It's not likely you use this method in practice

.

Frans Bouma | Lead developer LLBLGen Pro
alzchem
User
Posts: 2
Joined: 09-Sep-2015
# Posted on: 10-Sep-2015 09:14:42   

Thank you Otis,

but I can't find

DaoBase.CreateConnection CommonDaoBase.CreateConnection

May be i'm blind wink but I search this a long time....

What do I want to do? I would like to execute an old SQL-Statement. And I don't want to transfer it into LLBLGEN-Code. Just execute it like it is...

In LLBLGEN Pro v 2.6 i did it with RetrievalQuery:

var rq = new RetrievalQuery(new SqlCommand("Select id,* from sometable"));
            rq.Connection = DbUtils.CreateConnection();
            rq.Connection.Open();
            
            SqlDataReader test = rq.Execute(CommandBehavior.SingleResult) as SqlDataReader;
            var hasrows = test.HasRows;
            test.Read();

            var wert = test.GetGuid(0);

Now I change from 2.6 to 4.2 and miss CreateConnection ......

Thanks!

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 11-Sep-2015 08:08:52   

DaoBase is an abstract class. You can use the instance methods of an specific DAO (like CustomerDAO) or CommonDaoBase (which is common to all other DAOs in your project). Example:

cnn =new CustomerDAO().CreateConnection();
cnn =new CommonDaoBase().CreateConnection();
David Elizondo | LLBLGen Support Team