0

我有两个表
用户(Userid、Name、PhoneNumber)
应用程序(ApplicationsId、UserId、ApplicationName、ActiveDate)

每个用户将拥有超过 1 个应用程序。

在使用延迟加载的 Nhibernate 中,我可以获取用户数据以及每个用户的所有应用程序。所以,我曾经做一些类似 user.applications[i].Applicationname 的事情来获取所有的应用程序。

但是,现在我如何使用 oracle 命令检索所有应用程序以及用户数据。我知道如何使用连接获得一个应用程序。但是,我如何检索多个应用程序并将其存储在 IList 中。任何帮助是极大的赞赏。谢谢你。

4

1 回答 1

0

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.

于 2010-07-27T20:58:48.157 回答