C#: Generics

Please see my other C# articles. Ensuring type-safety in objects. Whenever performing domain modeling, it’s critical to ensure code matches the real-world environment as much as possible. The chief method for doing so to utilize classes by which objects may be instantiated. However, having a collection of objects that are either the incorrect type or contain incorrect…

C#: 4.0 Anonymous Types

Please see my other C# articles. Simple, elegant data storage. One of the latest improvements to the .NET Framework in 4.0 is the ability to use object initializers to create simple data-storage objects without having to create a class or struct. Also, these anonymously-typed objects are created by the compiler so you still have strong-typing on your…

C#: ADO.NET Transactions

Please see my other C# articles. Ensuring data-concurrency. When a feature requires an atomic action, ADO.NET transactions easily ensure data concurrency while performing writes against the database.For example, let’s say two separate db writes are needed, each of which executes a stored procedure.Should errors occur, it’s essential that both writes are rolled-back before any changes are…

T-SQL: Row_Number

Please see my other Database Development articles. Ranking Functions There are several new impressive advancements in the latest version of t-sql; this article will focus on “Ranking” functions. Prior to the release of SQL Server 2005 with its t-sql enhancements, working with blocks of related data was clunky at best. T-sql authors mostly relied on…

T-SQL: Synonym

Please see my other Database Development articles. Simplifying T-SQL syntax. Length T-SQL is unfortunately the byproduct of many business requirements in supporting an application. As the parts of each statement grows (database.schema.object), so the overall length of the entire query. Synonyms provide a painless method to drastically decrease code bloat in queries by allowing for…

T-SQL: String Search

Please see my other Database Development articles. Returning selection portions of values in a resultset. When searching for specific values within a field, returning portions surrounding the search criteria may be very helpful for providing the user a context in which the value in being used. In this example, I will illustrate searching within a…

T-SQL: Stored Procedure Default Values

Please see my other Database Development articles. Building flexibility into data INSERT operations. Often when designing an application that receives user input, it’s difficult to determine beforehand exactly which fields will be supplied where a user completes a form. SQL Server provides the ability to supply default values for parameters of stored procedures to allow…