Select Page

Art of BI: Simple SubSonic Project Collection Retrieve

Christian Screen | | July 4, 2009

Using the subsonic project ORM for .NET clearly has tons of benefits for DAL and BLL purposes.

A great way to get a list of records from the db is to use the collection object which is created for tables and view objects from the db.

Here are two examples of how to use the .Load() method and overload to get data in a collection for which you can loop through using a foreach() statement.

Using the Query Object with Collection Object


Query q = new Query(Views.Accounts);
q.WHERE("accountID", Comparison.Equals, _accountID.value.ToString());

AccountsCollection obj1 = new AccountsCollection();
obj1.Load(q.ExecuteReader());
[/sourcecode]

Using only the Collection Object
[sourcecode language='csharp']
AccountsCollection obj1 = new AccountsCollection().Where("accountID", Comparison.Equals, accountID.value.ToString()).Load();
[/sourcecode]
 

Now, to loop through the Collection
Once the collection has been instantiated and the Load() method called a foreach() loop can take place to get the records.
[sourcecode language='csharp']
if (obj1.Count > 0)
{
   foreach (Accounts x in obj1)
   {
      Console.Write("My Account Name is {0}", x.AccountName);
   }
}
else
   Console.Write("There are no accounts in the collection");

Subscribe to Our Blog

Never miss a post! Stay up to date with the latest database, application and analytics tips and news. Delivered in a handy bi-weekly update straight to your inbox. You can unsubscribe at any time.

Art of BI: BI Publisher (BIP) Quick Guide and Tips

Read our blog post on how to take over production support of BI Publisher reports.

Sherry Milad | January 15, 2018

Art of BI: How to Add Comments in Oracle BI (OBIEE)

Ultimately the goal of commentary in OBIEE is to have a system for persisting feedback, creating a call to action, and recognizing the prolific users.

Christian Screen | December 29, 2013

Art of BI: Uninstalling WebLogic Not Working on Windows OS

It isn’t often that one has to go about uninstalling WebLogic, the main application server for Oracle Fusion Middleware, when implementing Oracle BI or the EPM suite.

Christian Screen | September 10, 2013

Work with Us

Let’s have a conversation about what you need to succeed and how we can help get you there.

CONTACT US

Work for Us

Where do you want to take your career? Explore exciting opportunities to join our team.

EXPLORE JOBS