Andy Edinborough

Insert something cool to say here

Reading Entity Framework Code First Objects from a Stored Procedure

Posted on November 1, 2010 in Code    Tagged entity framework code first c# t-sql Tweet This

I may be a nerd (that is, a geek who get’s paid), but I don’t enjoy writing stored procedures.  However, in working with the Entity Framework, I’ve found that doing complex and often repeated queries of my Entity Framework sets is rather inefficient.  My complete round-trip page loads (generate and execute query, then produce HTML) takes about 1,000ms on average.  So I wanted to replace this ugly query with a simple stored procedure—precompiled, ready to fire, and highly optimized for my specific query, while still having the ability to do ad-hoc queries.

So at PDC10 I made sure to talk to the EF boys and they pointed me to the System.Data.Objects.ObjectContext.Translate method.  This little bad boy will take a DataReader and create an enumerable of my objects from it—perfect.

Let’s walk through the “gotchas”.  In my example below, I have a class named Product.  I want to do… Read More →

Use Late-Binding in C# Now, without .NET 4.0

Posted on June 17, 2009 in Code    Tagged .net c# late-binding Tweet This

The lack of late-binding in C# has been one of my biggest gripes about C#.  Finally, in the .NET Framework v4.0, the dynamic keyword has been introduced (it could be argued that it is too loose—allowing for variant types).  But until it is released, the need still exists, and even then, not all clients will immediately support it.  So, in a bind, I wrote a simple class to allow access to objects via late-binding in C#. 

The trick to figuring out how to write the code came from using Reflector to decompile some VB.NET code… (I love reverse-engineering :]).  The answer is that the VB compiler makes use of an area of the .NET Framework within the Microsoft.VisualBasic assembly that is marked with the attribute [EditorBrowsable(EditorBrowsableState.Never)] to prevent people from discovering it.

Here’s an example that uses my Late-Binding code to open an Excel Spreadsheet and convert it to a… Read More →

RE: Microsoft may be Firefox's worst vulnerability

A recent article at Slashdot that has now been propagated to TechRepublic, claims that Firefox's biggest vulernability this year is Microsoft.  For those who have not heard, as part of the .NET Framework v3.5 SP1, Microsoft added an extension to Firefox to support Click-Once application deployment.  The claim by Slashdot is that this is Internet Explorer's biggest vulernability and that Microsoft has forced it onto Firefox users.

Having done extensive development in the area, Click-Once deployment does not give the “ability for websites to easily and quietly install software on your PC”.  Click-Once must always be initiated by the user, always displays a dialog, and always requires the user to agree to install the software.  Microsoft didn’t do anything that Firefox doesn’t allow or encourage.  Click-Once is actually very similar to Firefox’s own method for downloading and installing Extensions.

The interesting thing is that the article claims this is… Read More →

© 2013 Andy Edinborough. All your rights are belong to me.