Wednesday, September 13, 2006

Design Patterns for .Net

Design Patterns for .Net

Behind the Scenes: Discover the Design Patterns You're Already Using in the .NET Framework -- MSDN Magazine, July 2005

Behind the Scenes: Discover the Design Patterns You're Already Using in the .NET Framework -- MSDN Magazine, July 2005

ASP.NET: Developing and Using a Custom Server Control

In general, when your control derives from WebControl and renders a single element, you should override the RenderContents method (and not the Render method) to render content within the control's tags. The Render method of WebControl invokes RenderContents after rendering the opening tag for the control and its style attributes. If you override the Render method to write contents, your control will lose the style-rendering logic that is built into the Render method of WebControl.

Tuesday, September 12, 2006

Custom Sort Order in SQL Server

არცთუ ხშირად, მაგრამ შესაძლებელია, საჭირო გახდეს მონაცემთა ბაზის ცხრილის სვეტის სორტირება არა ანბანის, არამედ რაიმე სხვა, თავისუფალი წესის მიხედვით. მაგალითისათვის, ავიღოთ Customers ცხრილი Northwind ბაზიდან Microsoft SQL Server -დან. დავუშვათ, გვინდა კლიენტების სორტირება ისე, რომ კლიენტები ამერიკიდან იყვნენ სიის თავში, მათ მოსდევდეს კლიენტები დიდი ბრიტანეთიდან და ა.შ. ერთერთი მეთოდი მდგომარეობს CASE კონსტრუქციინ გამოყენებაში. მომყავს სკრიპტი:
SELECT *
FROM Customers
ORDER BY
CASE country
WHEN 'USA' THEN 1
WHEN 'UK' THEN 2
WHEN 'Canada' THEN 3
WHEN 'Ireland' THEN 4
WHEN 'France' THEN 5
ELSE NULL
END,
customerid