Queries

Posts   
 
    
eirizarry
User
Posts: 48
Joined: 30-Mar-2011
# Posted on: 30-Mar-2011 23:02:21   

Can i run queries like the one that we run with the OleDb,

Ex. in VB.Net

Dim rsReader As OleDb.OleDbDataReader

Dim Qry as string = "select emplno, emplname from employee"

Dim rsCmd As New OleDb.OleDbCommand(Qry, MyDatabase.MyConn)

Dim rsReader = rsCmd.ExecuteReader()

but with the LLBLGen Framework

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 31-Mar-2011 05:08:29   

One of the ideas or an OR/M is that you don't need to do this kind of things. It's simpler, cleaner, typed, if you just us LLBLGen framework.

Said that, you can for special reasons, execute raw sql. Here are some related threads: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=12495 http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=12293

David Elizondo | LLBLGen Support Team
eirizarry
User
Posts: 48
Joined: 30-Mar-2011
# Posted on: 30-Apr-2011 18:05:37   

It is true, it is more better to do the change to LLBLGenPro, but we had a client/server applicacion with already more than a 1000 queries, some of them, like 200 are a little complex. Im a little rush to change the application to LLBLGenPro to get rid of some performance issues with the Oracle database.

I will like to get the complex query and use them as they already written in the code but using the LLBLGenPro and then with a little more time change one by one. I read the two post but i can not understand them. Can you post an example in this thread with the basic.

Per example, if i want to run a query like this.

Query = "select emplnum, name, birthdate from employee_table where emplnum=200"

how i can do it?

thanks in advance

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 01-May-2011 22:48:57   

Ok. This is an example:

using (DataAccessAdapter adapter = new DataAccessAdapter())
{
    // set my query
    SqlCommand cmd = new SqlCommand("select * from ...");
    RetrievalQuery query = new RetrievalQuery(cmd);

    // fetch reader
    IDataReader reader = adapter.FetchDataReader(query, System.Data.CommandBehavior.SingleResult);

    // loop though the reader...
}

You also could put your queries into stored procedures and then call them with LLBLGen. It's also recommended to read how to fetching data readers and projections.

Anyway, would be a good idea to start migrating your queries. That way you can take advantage of all the LLBLGen features wink

David Elizondo | LLBLGen Support Team