-
Using HiLo with FluentNHibernate posted on 24 Oct 2010
I spend ages trying to find some documentation or tutorial on how to use HiLo with FluentNHibernate after reading:
- NHibernate: Avoid identity generator when possible
- SCOPE_IDENTITY() sometimes returns incorrect value
- NHibernate POID Generators revealed
- Identity: The never ending story - BTW they are remaking The NeverEnding Story. Bastards!!!
As it turns out, it's really easy to setup. I figured out two ways of doing it, the HiLo table having a single row, with each column for each table 'Hi'. Or a row for each table.
I setup a really simple example with the following table.
'ProductId' is set to be int/primary key, but identity is false, since we don't want the database generating the id.
-
Google is fail posted on 15 Oct 2010
No longer is Microsoft the evil empire, for Google is the new emerging evil empire. Seriously, Google is the new M$ of the 90's.
It's always bugged me that I use Opera browser for my primary browser, a browser which follows W3 Standards more strictly than any other browser out there.
Yet so many sites fail to support Opera... I had to use IE for years just to do internet banking with ANZ bank, until Opera 9.5 came out, simply because they blocked it. Many other sites seem to suggest using a 'supported' browser, even tho the site works 100% in Opera anyway...
In comes Google, they always hold back on Opera. Google Wave? Gmail? Analytics, all had their issues over the years, and now we have this new super duper feature Google Instant, and their new fancy Image Search.
Except, neither work in Opera...
Except... It actually does work,infact both Google Instant and their fancy Image Search work in Opera.
-
Getting back into it :( posted on 28 Sep 2010
Earlier this year I changed hosting provider, had a new VSlice with Windows Server 2008 R2, SQL and all the wizz bang stuff. But within 3 weeks of setting everything up, everything went down, and I lost everything. Apparently the VM corrupted and couldn't be recovered. Not only that I made the mistake of thinking "hey, you know what, nothing bad will happen for a while, I'll setup backups next month". Only something bad did happen.
I've since moved host again, and am now hosted with MammothVPS with proper backups. So hopefully it doesn't die again.
It's pretty depressing to lose everything, I lost a couple of projects I had spent a couple of years building that had only been live a month or so. So depressing it put me off wanting to blog anything. So hopefully I can get back into it again.
-
QueryOver with NHibernate 3... Lovin it! posted on 28 Sep 2010
Working on an old website I built back in 2004, back then I coded all the data access by hand, wrote stored products and populated the data into objects, lazy loaded relationships etc. 2005 roles around and I migrated it to .Net 2.0, but with all the old data access stuff intact.
Move forward 6 years and I have to make some changes, so I figured I would update the data access to use NH3.0 so I could play around with it.
One of the thing's I just wrote was a sub query using exists. If I wrote the SQL it would probably look something along the lines of:
SELECT * FROM ProductType WHERE EXISTS (SELECT 1 FROM Product WHERE Active = 1 AND ProductTypeID = ProductType.ProductTypeID)
With some more criteria, since the data comes from MYOB it's sometimes out of date, I check for status, active, quantity,price,etc.
Originally this stuff was in a stored procedure, and I needed to write this using QueryOver.
-
jQuery Serialize a Fieldset posted on 11 Jul 2009
I'm really not a fan of ASP.Net Ajax and would prefer to use jQuery where ever I can. So for anything public facing I tend to use jQuery and HTTPHandlers.
jQuery has this nifty little function called serialize for serializing form data for Ajax. So if we have the following HTML.
<body> <form id="aspNetForm" runat="server"> <div> <fieldset class="fsLoginForm"> <legend>Login Fieldset</legend> <ul> <li>Email: <input type="text" name="txtEmail" /></li> <li>Password: <input type="text" name="txtPassword" /></li> </ul> </fieldset> <fieldset class="fsName"> <legend>Name Fieldset</legend> <ul> <li>My Name: <input type="text" name="email" /></li> </ul> </fieldset> <fieldset class="fsColour"> <legend>Colour Fieldset</legend> <ul> <li>Colour: <input type="text" name="colour" /></li> </ul> </fieldset> <input type="button" value="Submit Form" onclick="SubmitForm();" /> </div> </form> </body>
And a basic alert method that shows us the result of the form serialized:
function SubmitForm() { alert($('form').serialize()); }