LessThanDot Site Logo

LessThanDot

A decade of helpful technical content

This is an archive of the posts published to LessThanDot from 2008 to 2018, over a decade of useful content. While we're no longer adding new content, we still receive a lot of visitors and wanted to make sure the content didn't disappear forever.

How Does Between Work With Dates In SQL Server?

Do you use between to return data that has dates? Do you know that between will get everything since midnight from the first criteria and up to midnight exactly from the second criteria. If you do BETWEEN 2006-10-01 AND 2006-10-02 then all the values that are greater or equal than 2006-10-01 and less or equal to 2006-10-02 will be returned. So no values after 2006-10-02 midnight will be returned. Let’s test this out, first let’s create this table

Read More...

StructureMap: Configure everything before using Objectfactory.GetInstance

I just found out today that you have to have everything configured in structuremap before calling getInstance. I am using structureMap 2.4.9. To test this I created. 2 interfaces. Namespace Interfaces Public Interface IClass1 Sub somefunction() End Interface End Namespace``` ```vbnet Namespace Interfaces Public Interface IClass2 Sub someotherfunction() End Interface End Namespace``` And 2 Classes. ```vbnet Public Class Class1 Implements Interfaces.IClass1 Public Sub somefunction() Implements Interfaces.IClass1.somefunction Console.WriteLine("class1") End Sub End Class Public Class Class2 Implements Interfaces.

Read More...

My Path to the Dark Side part 4 – the Repositories

Previous posts can be found here: Part One – The Beginning Part Two – The Domain Model Part Three – Testing the Schema Setting up the repositories for our objects is where this really starts to get fun for me. This is what allows us to work with the persisted objects so easily from our application code, without all the SQL getting in the way. The first thing we want to think about here is what we need the repository to do.

Read More...

Some of the blogs I read

If you want to learn then you have to read and I read blogs (among other things). But how do you find the good things to read? It takes a while to find the good blogs, so here is a little list. Most of these guys do C# programming so I have to translate to adapt it to my situation but I don’t mind. Lets start with Ayende Rahien he is the maker of much useful software like Rhino mocks and some other things starting with Rhino.

Read More...

nHibernate performance against stored procedures: Conclusion

Index Prelude Part 1 Part 2 Part 3 Conclusion So here we are. We all saw the figures. Nothing we didn’t already know, so let’s not dwell on the obvious. NHibernate will always be slower than the rest. If you look at the figures and decide not to use NHibernate or any other ORM from now on, then go right ahead, you just missed the point altogether. You didn’t notice the rest of the design did you?

Read More...

nHibernate performance against Stored procedures part 3

Index Prelude Part 1 Part 2 Part 3 Conclusion This is going to be another lengthy post. But you can skip all the code bits and go to the end. Or wait a bit and read the conclusion in the last post. First, nHibernate needs some sort of configuration ```vbnet Imports NHibernate.Mapping.Attributes Imports NHibernate Imports NHibernate.Cfg Imports StructureMap Namespace DAL.CRUD.Hibernate “’ <summary> “’ “’ </summary> “’ <remarks></remarks> <CLSCompliant(True)> _ <Pluggable(“Live”)> _ Public Class NHibernateConfiguration

Read More...

Converting Columns To Date From Datetime Does Not Result In A Scan In SQL Server 2008

I was reading Itzik Ben-Gan’s An Introduction to New T-SQL Programmability Features in SQL Server 2008 article yesterday after one of my friends allerted me to the following from that article For example, the plan for the following query performs an index seek on the index on the CurrencyRateDate DATETIME column: USE AdventureWorks; SELECT FromCurrencyCode, ToCurrencyCode, EndOfDayRate FROM Sales.CurrencyRate WHERE CAST(CurrencyRateDate AS DATE) = '20040701'; I was surprised by this, as we all know functions/conversions on column names are generaly bad for performance.

Read More...

nHibernate performance against Stored procedures part 2

Index Prelude Part 1 Part 2 Part 3 Conclusion Yes The stored procedures came to town. Here is the first one. CREATE PROC spo_getMspCoordinates AS SELECT TOP 1000000 id, a, WaveLenghtinnm FROM dbo.tbl_MSPCoordinate GO This just gets the first million out of that database. Now we hit a snag and something that kills performance. But I can’t think of a reasonable way around it without using dynamic sql.

Read More...

nHibernate performance against Stored procedures part 1

Index Prelude Part 1 Part 2 Part 3 Conclusion So like I promised I would write a little comparison. First: Is this really useful? No, not really just an interesting exercise. Because in the end performance isn’t everything. So here we go. First I created a table. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tbl_MSPCoordinate]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [dbo].[tbl_MSPCoordinate] GO CREATE TABLE [dbo].[tbl_MSPCoordinate] ( [Id] [bigint] IDENTITY (1, 1) NOT NULL , [MSP_id] [varchar] (36) COLLATE Latin1_General_CI_AS NULL , [WaveLenghtinnm] [decimal](19, 5) NOT NULL , [A] [decimal](19, 5) NOT NULL , [Added_By] [varchar] (20) COLLATE Latin1_General_CI_AS NULL , [Added_On] [datetime] NULL ) ON [PRIMARY] GO``` Well I already had this and it happens to be filled with rows.

Read More...

nHibernate performance against Stored procedures

Index Prelude Part 1 Part 2 Part 3 Conclusion There is this very interesting blogpost by Robert Johnson on his “I am not Myself Blog“. I will be testing this on my servers first thing in the morning. Please keep watching this channel. So I have tested it: Part 1. Don’t forget to read the conclusion (before you start flaming). Need help with VB.Net? Come and ask a question in our VB.

Read More...