Blog posts page 9 of 44

LINQ to SQL tips and tricks #3

  • πŸ“…
  • πŸ“ 925
  • πŸ•™ 5
  • πŸ“¦ .NET
  • πŸ’¬ 3

Another set of useful and lesser-known LINQ to SQL techniques.

LINQ to SQL supports stored procedures for retrieving entities, insert, update and delete operations, as you know. But you can also use them to perform lazy-loading of navigation properties.

Origins of a love affair

From an earliest memory of a cream colored box emblazoned with letters, mostly black – some red, came an owl proclaiming allegiance to the BBC.

This small box sat silently, patiently even, in our classroom for the best part of a year. On the few occasions our teacher was brave enough to flip the switch the machine would chirp into life with it’s two-tone beep and would state on capital white letters on a black background that it was BASIC. At this point the teacher would key-in the mythical incantation of CHAIN ""CHAIN "" – handily jotted on a nearby note – and feed the beast a cassette tape.

SQL Server query plan cache – what is it and why should you care?

SQL Server like all databases goes through a number of steps when it receives a command. Besides parsing and validating the command text and parameters it looks at the database schema, statistics and indexes to come up with a plan to efficiently query or change your data.

You can view the plan SQL Server comes up with for a given query in SQL Management Studio by selecting Include Actual Execution Plan from the Query menu before running your query.

When an object-relational mapper is too much, DataReader too little

  • πŸ“…
  • πŸ“ 248
  • πŸ•™ 2
  • πŸ“¦ .NET
  • πŸ’¬ 16

I fired up Visual Studio this evening to write a proof-of-concept app and found myself wanting strongly typed domain objects from a database but without the overhead of an object-relational mapperΒ  (the application is read-only).

One solution is to write methods by hand, another is to code generate them but it would be nice to be able to do:

First impressions of Snow Leopard

I came home from work today to find my family pack upgrade version of Snow Leopard. It’s been a few hours, so here are impressions so far.

The packaging was very small and lightweight and eco-friendly compared to the big-plastic-box-monsters that come out of Redmond.

LINQ to SQL cheat sheet

A few short words to say I’ve put together a cheat sheet for LINQ to SQL with one page for C# and another for VB.NET.

It shows the syntax for a number of common query operations, manipulations and attributes and can be a very useful quick reference :)

Dictionary<T> look-up or create made simpler

  • πŸ“…
  • πŸ“ 236
  • πŸ•™ 2
  • πŸ“¦ .NET
  • πŸ’¬ 6

The design of a Dictionary<T>Dictionary<T> lends itself well to a caching or identification mechanism and as a result you often see code that looks like this:

It’s not that it is particularly difficult but it can be a bit error prone and when you’re doing it over and over. What would be nicer is something that let you do: