Posts

Showing posts from July, 2011

LINQ Expressions, The Specification Pattern and Repositories

Disclaimer : I am unsure if what I am about to show here is a bridge too far in terms of bastardising the specification pattern ... it very well may be the case. However, Linq has provided a new paradigm that needs to be embraced, and sometimes that requires the tweaking of existing pratices and patterns. Background Info For some background on this article I recommend reading the following primers. I would never have to got to where I did without them. Please check out: Implementing the Specification Pattern via Linq [http://ubik.com.au/article/named/implementing_the_specification_pattern_with_linq] Linq, the Specification Pattern and Encapsulation [http://www.iridescence.no/post/Linq-the-Specification-Pattern-and-Encapsulation.aspx] Implementing ORM-independent Linq queries [http://rabdullin.com/implementing-orm-independent-linq-queries/] The Goal I wanted a flexible way to leverage the deferred execution power of Linq in my application. The logical place f...

Reasons why Cloud Computing is efficient

I can think of four reasons why cloud computing is (with few exceptions) significantly more energy efficient than using in-house data centers: 1. Economies of scale. It’s cheaper for bigger cloud computing folks to make efficiency improvements because they can spread the costs over a larger server base and can afford to have more dedicated folks focused on efficiency improvements. For example, there are usually significant fixed costs of implementing simple techniques to improve Power Usage Effectiveness (PUE), like the costs of doing an equipment inventory and assessment of data center airflow (same for implementing institutional changes like charging users per kW instead of per square foot of floor area). Whenever there are costs that are substantially fixed (i.e. only weakly related to the size of the facility), bigger operations have an advantage because they can spread the costs over more transactions, equipment, or floor area. There’s also a substantial advantage to having “in h...

SQL SERVER – T-SQL Scripts to Find Maximum between Two Numbers

I found there is a simple way to write query to get the maximum of two numbers in SQL Server. Method 1: DECLARE @Value1 DECIMAL(5,2) = 9.22 DECLARE @Value2 DECIMAL(5,2) = 8.34 SELECT (0.5 * ((@Value1 + @Value2) + ABS(@Value1 - @Value2))) AS MaxColumn I thought his logic was accurate but the same script can be written another way. I quickly wrote following code for him and which worked just fine for him. Method 2: DECLARE @Value1 DECIMAL(5,2) = 9.22 DECLARE @Value2 DECIMAL(5,2) = 8.34 SELECT CASE WHEN @Value1 > @Value2 THEN @Value1 ELSE @Value2 END AS MaxColumn For me Method 2 is looks simpler than Method 1.

SQL SERVER – Insert Multiple Records Using One Insert Statement

Earlier I was struggling a lot by writing multiple statements for each Insert to the single table. Infact in Respond, we have to write individual classes for each statement. At last I got a solution to manage with a single statement. Absolutely helpful to me that I will be able to insert multiple rows in SQL with using only one SELECT statement. Previous method 1: USE MyDB GO INSERT INTO MyTable (FirstCol, SecondCol) VALUES ('First',1); INSERT INTO MyTable (FirstCol, SecondCol) VALUES ('Second',2); INSERT INTO MyTable (FirstCol, SecondCol) VALUES ('Third',3); INSERT INTO MyTable (FirstCol, SecondCol) VALUES ('Fourth',4); INSERT INTO MyTable (FirstCol, SecondCol) VALUES ('Fifth',5); GO Previous method 2: USE MyDB GO INSERT INTO MyTable (FirstCol, SecondCol) SELECT 'First' ,1 UNION ALL SELECT 'Second' ,2 UNION ALL SELECT 'Third' ,3 UNION ALL SELECT 'Fourth' ,4 UNION ALL SELECT 'Fifth' ,5 GO SQL Server 2008 Me...