BizBlox Find/Fetch methods explained

21 01 2010

by Stephen Trembath

Just a quick summary of the DOCollection methods and how they work at the query level.

I will add to documentation eventually once I refine this a bit more, and maybe reduce the number of methods:

Take for example a CustomerCollection, comprised of Customer DataObjects. For the below examples the query will find customers with FirstName=Stephen

SetCurrentQuery
Simply sets a SqlBuilder as the query to run on the DOCollection – does not actually run any SQL.
To run the query you have to use one of the below methods. If you do not run any of the below methods, and try to access DataObjects within the collection, it will default to running the Find() method.

Find
For the current query, selects all IDs:
e.g. SELECT CustomerID FROM Customer WHERE FirstName=’Stephen’

Only when the actual Customer objects are accessed is the DataObject loaded via a new SQL query:
e.g. if you do custColl(0) it will run: SELECT Customer.* FROM Customer WHERE CustomerID = ‘……’

Iterating through a large collection, can result in a lot of queries – i.e. one to select all IDs, and one to select details of each DataObject you access.

Fetch
Retrieves all data for all matching rows in the query:
e.g. SELECT Customer.* FROM Customer WHERE FirstName=’Stephen’

This returns more data, but there is no need for follow-up queries to retrieve customer information.

FindAll
Works like a Find, but disregards the current query, and instead finds all matching IDs within the table
e.g. SELECT Customer.CustomerID FROM Customer

Should be used sparingly.

FetchAll
Works like a Fetch, but disregards the current query, and instead finds all matching IDs within the table
e.g. SELECT Customer.* FROM Customer

Should be used sparingly.

Count
If the DOCollection has been populated by a Find/Fetch etc, this will just return the number of rows from the collection itself.

If the DOCOllection has not been populated, this will do a SELECT Count(*) FROM Customer

FindRange
Returns a subset of the rows retrieved by the query. e.g. custColl.FindRange(50, 99) will skip the first 50 rows and return the following 50.

It does this by finding all IDs that match the query, while using a SELECT TOP to minimize the upper range

(e.g. SELECT TOP 100 CustomerID FROM Customer WHERE FirstName=’Stephen’)

It then manually removes in code the IDs that are not needed, e.g. the first 50 IDs in this case.

After that, accessing each DataObject will result in a SELECT Customer.* FROM Customer WHERE CustomerID = ‘……’ type query.

FetchRange
Similar to FindRange() except that it does a SELECT(*) to retrieve all data, e.g. custColl.FetchRange(50, 99) will skip the first 50 rows and return the following 50.

(e.g. SELECT TOP 100 Customer.* FROM Customer WHERE FirstName=’Stephen’)

It then manually removes in code the DataObjects that are not needed, e.g. the first 50 DataObjects in this case.

Generally not recommended.

FetchSelected
This is a new method that is still under development for general use, and needs to be defined better. It is best used where performance is crucial, and where the query is not overly complex.

It is similar to FindRange but uses SQL Server 2005′s built-in paging for efficiency, using the ROW_NUMBER function:
http://www.davidhayden.com/blog/dave/archive/2005/12/30/2652.aspx

It also only selects the columns explicitly entered in the SqlBuilder (you can still add a SELECT *)

However, with that comes a greater chance for limitations in queries, and should only be used for now where fullt tested.

The ROW_NUMBER function will only return from the database the actual rows that are required, and there is no need for manual removal in code.

e.g. Case 1:
Dim mySql as New SqlBuilder(“Customer”)
mySql.addSelect(Customer.

Columns.CustomerID)
mySql.addSelect(Customer.Columns.FirstName)
mySql.addSelect(Customer.Columns.LastName)
mysql.addWhere(Customer.Columns.FirstName, ‘Stephen’)

custColl.FetchSelected(50, 99)

The query will be similar to the following, but using the ROW_NUMBER syntax to retrieve the desired rows:
SELECT Customer.CustomerID, Customer.FirstName, Customer.LastName FROM Customer WHERE Customer.FirstName=’Stephen’

e.g. Case 2:
Dim mySql as New SqlBuilder(“Customer”)
mySql.addSelectAll()
mysql.addWhere(Customer.Columns.FirstName, ‘Stephen’)

custColl.FetchSelected(50, 99)

The query will be similar to the following, but using the ROW_NUMBER syntax:
SELECT * FROM Customer WHERE Customer.FirstName=’Stephen’





BizBlox 1.7.2 Release

10 07 2009

The latest update to BizBlox has been released today. This update has fixes for unicode support and a small issue with transaction management.

  • BizBlox used to use the local database collation settings for handling content, however this update forces unicode coalescence to comply with the way .Net handles strings (all unicode!) and makes dealing with multilingual content a no-brainer.
  • Failed transactions will no longer throw ‘null reference exception’.

Get the latest release from http://www.pixolut.com/bizblox





BizBlox 1.7: New fundamentals

6 04 2009

The BizBlox OR/M API has been in development for 5 years and is actively used in many commercial enterprise and light weight applications around the globe. The key premise of BizBlox has always been to keep databases simple. NO MAPPING, no complexity, no scripts. Its funny that layers on top of nHibernate like Fluent and even the Microsoft Linq for SQL have been trying to get this right over the last year or so – but BizBlox did it this way from the beginning. Naming parity; where classes names should match table names; property names should match column names makes perfect sense for a lot of applications and the complexities which a lot of object relational mappers introduce makes life hard for developers; both initially and especially further down the track in maintenance. Also, removing the need for special mapping scripts or weird GUI mapping tools. Just export your SQL from the enterprise manager/management studio and you’re done. Developers can just concentrate on developing business logic.

Pixoüt have just released BizBlox 1.7 on Google Code. The new version delivers greatly increased performance and flexibility, with major improvements to the DataObject caching algorithm, the addition of column attributes to the DataObject class, and the ability to handle a greater range of data types.
BizBlox 1.7 now caches information about the structure of a DataObject, including properties and column information. This information was previously loaded using reflection on every Load() and Save() of a DataObject, but it is now cached in a DOInfo object the first time an instance of that DataObject is created. While there is a minor performance penalty on the very first load of an instance of the type in the App Domain, subsequent performance will be improved as there is no locking or reflection on any object.

BizBlox 1.7 also introduces column attributes in DataObjects, including PrimaryKey(), Persists() and Identity() attributes. The PrimaryKey() attribute provides flexibility in selecting the UID column for the DataObject. The Persists() attribute allows the addition of custom properties to a class that are not saved to the database. The Identity() attribute allows the use of a SQL Server Identity (auto-incrementing) column, by excluding that column from an insert/update.

You can find out more about BizBlox by going to the BizBlox home page. BizBlox is an open source database mapping framework developed by Pixolüt Industries.





BizBlox 1.5.1 Released

23 10 2007

BizBlox 1.5.1 Released
http://www.pixolut.com/bizblox

+: Added `Launch BizBlox Builder’ to installer finish screen
x: Fixed bug with UNIQUE constraints being parsed as Primary Keys in SQL Server 2005-generated scripts
x: Updated the install script for less (!) .Net support – useless carry over
x: Fixed long standing file association bug, BBX files are now associated correctly.
x: Fixed bug with default values not working for DateTime mapping and BoundsCheck project options

Stephen has been kind enough to push his latest bug fixes to a complete release and I finally had a chance to fix the install script a little from when we migrated BizBlox Builder from being closed source and set it free!

Remember that we have started providing consulting for developers wishing to integrate BizBlox in their commercial applications (which you can since BizBlox is released under the LGPL)  through the SourceForge Services Marketplace. Its early stages, but I can see that the drive for a structured approach to integration and consulting services for the huge number of open source projects is a great opportunity.





Multilingual Searching is not International Searching

19 10 2007

http://googleblog.blogspot.com/2007/10/helpful-suggestions-around-globe.html

I was reading this status update post from the Google team and it made me think about multilingual searching. The deeper issue of globalization is not necessarily the language – its the character set. The character set is what makes searching for Russian content from a computer in the United States very difficult. You need to set up your keyboard language to Russian and then try to figure out how to make all the symbols. This probably doesn’t seem like a big deal to someone in the United States, however when you work for a multinational company in Europe it really is.

About four years ago I was working on a project which was using the early version of BizBlox and the client was NASDAQ listed with US offices but the primary user group was a European food conglomerate. The system I was developing managed advertising assets for over 2000 brands across about ten different languages. The core problem was that some of the most important people searching the system were based in the United States and they didn’t know anything about character sets or international search – but they knew what they wanted because they knew what the words ‘looked like’.

The solution was actually really simple. For every latin based character set (non Asian, Aramaic or Sanskrit) there are similarities in letterform which can be assigned to a standard ‘sort-of’ equivalent US keyboard character or combination thereof. This solution was about leveraging the visual recognition of the end user against the foreign character set – so sometimes – especially with the Greek character set – there is more than one character which can match (not necessarily a one to one relationship between letterform similarity). The BizBlox codebase to this day has the simple version of the visual-multi-lingual character mapping table in its very simple search engine.

This concept is by no means original – it has existed for as long as multiple symbol sets and languages have… the real idea here is that there is more than one way to recognize symbols of other languages and all of them should be treated equally. To the untrained eye is the word ἄβουλος transcoded to the English character set as aboulos or abovaos? It should not matter.

By using this idea in a search query it means that – in its simplest form – a search for the letter e in a word could also find words containing è, é, ê, or ë – or using a much more complex example – a search for a word with the letters TH, T or O could find a word with the letter Ɵ in it (the Greek letter Theta).

So how does this have anything to do with Google? Well, the suggestion feature allows for powerful and truely global search -but by adding this multi-directional character search context to suggestions it would be powerful across borders as well as inside them.

[Updated a ping back to a new article which outlines some of the ideas made in this post over a year ago. http://googleblog.blogspot.com/2008/11/our-international-approach-to-search.html ]





New releases coming next week: PreNIS2 and BizBlox Builder

10 08 2007

We have been busily migrating our core technologies from .Net 1.1 to .Net 2.0 – that is nearly two million lines of code across several projects and I have to say that it is testament to the Visual Studio 2005 environment that it has taken two developers less than a week to complete most of the migration. Increadible…

 Whilst we were at it, we found that there were some tools which had been left behind and needed a refresh:

 PreNIS, the NullSoft Install System pre-processor is going to version TWO next week. It now supports Visual Studio 2005 projects and also supports more advanced developer UI suites like Infragistics where they do not always ‘copy local’ all of the DLLs, but they are needed for web deployment.

The other product which desperately needed a refresh was the BizBlox Builder. Since the open source API went to version 1.4 it has supported Visual Studio 2005, however the Builder has not supported the newer SQL Schema of SQL2005 until now. You can now dynamically create thousands of lines of ORM code from the Builder using either SQL2000 or SQL2005 generated scripts.

Final testing is next week and releases will be up by then. If you’re really keen you can check out the current trunk on PreNIS to see what the new verison is capable of.





BizBlox 1.4 Released with .Net 2.0 Support!

9 03 2007

Well, we have finally gotten BizBlox ported to .Net 2.0 and using ADO2 specific features. There is an updated preview installer available on SourceForge with the two streams in one (.Net 1.1 and .Net 2.0).

BizBlox now supports a much better transactional model and also features some minor updates to be compliant with C# and CLS 2.0.

It was a tough decision to make BizBlox development become two independant streams and will mean a little more work in the code maintenance, but at the end of the day there are too many advanced, powerful .Net 2.0 native feaures which the API should provide access to, so we chose to create two streams in the source trunk and not simply do a ‘permanent branch’.

The first impact of making this decision is that the .Net 1.1 version of BizBlox does not support the new transactional features which the .Net 2.0 version does, yet the 2.0 version is backwardly compatible with the 1.1 version. I think this is a situation which will ocntinue to emerge as we continue on development.

The 1.4 release will be tidied up and the BizBlox Builder code generation engine for 1.4 will be released as soon as we have a stable and fully documented API release.

Get BizBlox now…
http://www.sourceforge.net/projects/bizblox





Big News for 2007

4 01 2007

Lots happening for Pixolüt in 2007.

Firstly, I would like to let you know that we will be releasing the BizBlox API on SourceForge as an Open Source project. The BizBlox Builder will remain the commercial developer product that it is, however given the existing flexible license which the BizBlox API used, we decided that it made sense to convert the API and library to an LGPL and release it to the open source community.

There are several benefits in doing this which will benefit all users and customers using BizBlox. First of all, it allows other code generation systems to be used on the BizBlox platform and not just our BizBlox Builder. Secondly, it opens our code to public scrutiny – yet allows for our continued control over the direction of the platform – allowing for a more robust and secure product. Finally, it allows access to the technology to the greater developer community and that’s always a good thing.

So what is the commercial benefit of selling the BizBlox Builder software if the most important part is free? Well, BizBlox Builder has been designed to integrate with the BizBlox library from the beginning, it comes with loads of example code in C# and VB.Net and also integrates with Visual Studio natively. We also provide enterprise support for our customers. All in all, as the director of Pixolüt and chief architect of the BizBlox ORM I feel like we have made right decision in opening the platform to the developer community and I hope many people can benefit from our research and development over the past three years.

We will have binary releases and the SubVersion repository ready for use by mid-January.

Pixolüt will also be releasing PreNIS under the LGPL as another project on SourceForge within the next couple of months and we aim to have a .Net 2.0 / VS2005 version of it ready for April.





General Stuff…

6 09 2006

Everything is moving along at the usual breakneck pace… I’m not sure if I have written anything about this previously, but we have been building our new house/the new Pixolut premesis over the last few months and its really starting to take shape. We are up to formworking the upstairs concrete slab and stairs.

Of course this has also consumed a heck of a lot of time in working with all the guys on the job getting things right in that translation from plan to reality. We essentially have spent about 5 years revising plans and now its all happening -0 very exciting.

At Pixolut we have updated BizBlox a lot with new tutorials, API documentation and knowledge base articles. We are in the process of arranging distribution with Component Source – so you should see your favourite ORM in a store near you soon. (Eh!?!)

Been doing a little skateboard homework too. These are great resources…
Tony Hawk Trick Tips
www.board-crazy.co.uk

An interesting Joe link:
http://www.linkedin.com/in/pixolut





BizBlox 1.0 FINALLY RELEASED COMMERCIALLY!

14 06 2006

After several months of POUNDING the BizBlox library in production environments I have finally had to make some changes to the API; whilst I was at it I have finally completed the remainder of the work to get BizBlox up to 1.0!

To read more about BizBlox or finally buy it, click here

Some major new features of the BizBlox Suite are:

  • Code generation and library API compatiblity in C# and VB.Net
  • All existing .9.x code will work on 1.0 with simply a rebuild
  • Command Line BizBloxBuilder which can be used in ant (automated) build scripts
  • BizBloxBuilder supports drag and drop and double-click with project files
  • Existing .9.x project files work on 1.0 automatically
  • Even better API help
  • BizBloxBuilder works with source control environments allowing partial runs of project files (just checked out files)Key new features of the API are:
  • Select data in a range
  • Intelligent collection finders
  • native guid support
  • Public access to SQLBuilders and SearchBuilders
  • Better databinding performance and memory managementIts been a long time coming, but I am sure you will find its been worth the wait. Upgrade today!