Linq To Sql Include(“table”)

If you are not using “Lazy Loading” on Linq to SQL or EF, you have to join other tables using Include(“”) statement. Worse thing about this extension it takes string argument. If you change the db schema then you have to be careful about those Include statements. recheck all of them or you have to rely on unit tests (That’s why we need unit testing).

Damien Guard made an excellent solution for this particular problem. You can use his extension as strongly-typed include statements.

Here is the extension method:

public static IEnumerable<T> Include<T, TInclude>(this IQueryable<T> query, Expression<Func<T, TInclude>> sidecar) {
   var elementParameter = sidecar.Parameters.Single();
   var tupleType = typeof(Tuple<T, TInclude>);
   var sidecarSelector =  Expression.Lambda<Func<T, Tuple<T, TInclude>>>(
      Expression.New(tupleType.GetConstructor(new[] { typeof(T), typeof(TInclude) }),
         new Expression[] { elementParameter, sidecar.Body  },
         tupleType.GetProperty("Item1"), tupleType.GetProperty("Item2")), elementParameter);
   return query.Select(sidecarSelector).AsEnumerable().Select(t => t.Item1);
}

Here is an example:

var oneInclude = db.Posts.Where(p => p.Published).Include(p => p.Blog));
var multipleIncludes = db.Posts.Where(p => p.Published).Include(p => new { p.Blog, p.Template, p.Blog.Author }));

Excellent solution. Check it out.

Post to Twitter Post to Plurk Post to Yahoo Buzz Post to Delicious Post to Digg Post to Facebook Post to MySpace Post to Ping.fm Post to Reddit Post to StumbleUpon

Outlook 2010 Context Menu

Why do you right click on the Deleted Items folder on Outlook?

  • Open in New Window?
  • New Folder?
  • Copy Folder? (:))
  • Mark All as Read?

Whats wrong with this people. Only reason I right-click on Deleted Items folder is to empty that folder, right?

So can you see where is the Empty Folder?

Post to Twitter Post to Plurk Post to Yahoo Buzz Post to Delicious Post to Digg Post to Facebook Post to MySpace Post to Ping.fm Post to Reddit Post to StumbleUpon

MVC Browse with option

If you are using several browser to check your MVC application, changing the default browser such a big problem.

If you looking for “browse with…” menu item on the context menu there isn’t. Its obviously smart thing because .aspx files are not exactly actual files, they are controlled by controllers in MVC application.

To get “browser with…” option you have two choice.

You can open your all favorite browser and copy paste your development links across the browser or add a default.aspx page to root of application.

Second option works just great. On the root of MVC application right click and say:

Add > New Item and choose > “MVC (2) View Page” rename page as “Default.aspx”. Now gonna see “browse with…” option when you right click on the “Default.aspx” page.

Post to Twitter Post to Plurk Post to Yahoo Buzz Post to Delicious Post to Digg Post to Facebook Post to MySpace Post to Ping.fm Post to Reddit Post to StumbleUpon

Introducing Microsoft SQL Server 2008 R2

The book contains 10 chapters and 216 pages, like so:

PART I   Database Administration

CHAPTER 1   SQL Server 2008 R2 Editions and Enhancements 3
CHAPTER 2   Multi-Server Administration 21
CHAPTER 3   Data-Tier Applications 41
CHAPTER 4   High Availability and Virtualization Enhancements 63
CHAPTER 5   Consolidation and Monitoring 85

PART II   Business Intelligence Development

CHAPTER 6   Scalable Data Warehousing 109
CHAPTER 7   Master Data Services 125
CHAPTER 8   Complex Event Processing with StreamInsight 145
CHAPTER 9   Reporting Services Enhancements 165
CHAPTER 10   Self-Service Analysis with PowerPivot 189

Check it out!

Post to Twitter Post to Plurk Post to Yahoo Buzz Post to Delicious Post to Digg Post to Facebook Post to MySpace Post to Ping.fm Post to Reddit Post to StumbleUpon

Visual Studio 2010 Keybinding Cards

Reference cards for the default keybindings in Visual Studio 2010 for Visual Basic, Visual C#, Visual C++ and Visual F#.

A high quality, print-ready PDF containing the default keybindings in Visual Studio 2010 for Visual Basic, Visual C#, Visual C++ and Visual F#.

Download it from here.

Post to Twitter Post to Plurk Post to Yahoo Buzz Post to Delicious Post to Digg Post to Facebook Post to MySpace Post to Ping.fm Post to Reddit Post to StumbleUpon