views:

49

answers:

1

Hello Friends, I have two tables
Users (Userid, Name, PhoneNumber)
Applications (ApplicationsId,UserId, ApplicationName, ActiveDate)

Every user will have more than 1 application.

In Nhibernate using lazy loading I can get the users data along with all the applications for every user. So, I used to do something like user.applications[i].Applicationname to get all the applications.

But, Now how do i retrieve all the applications along with the users data using oracle commands. I know how to get one application using joins. But, how do i retrieve multiple applications and store it in a IList. Any help is greatly appreciated. Thank you.

A: 

First you should download the Oracle Data Provider for .NET in http://www.oracle.com/technology/tech/windows/odpnet/index.html

after you make sure that you can open a connection to your oracle database then define mapping file of your entities in Nhibernate and map table columns of your oracle table to .NET object. after that you can use the following code snippet to get the list of your entity from database


// create the query...
IQuery query = session.CreateQuery( "from Post p where p.Blog.Author = :author" );

// set the parameters...
query.SetString("author", (String) instance);

// fetch the results...
IList results = query.List();

You should define the (Post) entity and (Blog) entity to your mapping file and as you can see (Post) has relation to (Blog) entity which is defined in the mapping file too.

Ehsan
Thanks for the reply. I total want to get rid of nhibernate and use plain oracle commands to get the data. I have been using nhibernate since 1 year now and i total forgot how to use normal oracle commands to get the data. Is there any other way to get the data without using nhibernate. Btw i can open the connection to the oracle database.
kalyan
You can simply use ADO.NET commands, you can find tons of example by googling this
Ehsan