SQL

Select Random Records Using Nhibernate

Selecting 5 random rows in SQL is easy

Nhibernate is a different story.  I am new to NHibernate and I both love and hate it.  I hate the steep learning curve and the unobvious ways of doing things.  Anyway, here is how to select 5 random records using nhibernate. First class a new order(…)

Dynamically Build LINQ Queries Using Reflection

I was recently working on a project where there was an option to export data from the database.  The export function simply exported 2 hard-coded columns that were returned by a stored procedure into a tab-delimited text file.  The sproc looked something like select id, name from mytable (I am over simplifying of course).  I(…)

Custom sort order in a SQL statement

I tracked a status of a record in a text field and wanted to sort the results in a specific order. For example I want “active” to show before “rejected” and “deleted” to show up last, etc… It turns out it was pretty easy to do in SQL. Here it is: select * from viewoffers(…)