Replacing method calls with expressions at runtime with Linqkit and the Entity Framework

LINQ to Entities does not recognize the method ‘…’ method, and this method cannot be translated into a store expression. Does this sound familiar to you? It’s a common issue that many developers face, as evidenced by the astronomical amount of questions about it on stackoverflow.com The problem To understand why this happens, you must first realize that Linq To Entities - the thing that produces the SQL statements for you - never really executes your C# code. So when you write: ...

March 9, 2013 · 11 min · Alexander Moerman

Applying the builder pattern to the .Net MVC TagBuilder

Sometimes I’m a nitpicker. Actually I’m a nitpicker 24/7, but I can’t really say that on a blog, can I? So today’s nitpicking is about C#’s TagBuilder. This class allows you to build html without writing a single ‘<’ or ‘>’. Using this class usually boils down to something like this: // this will create <button> var input = new TagBuilder("button"); // Set some attributes input.Attributes.Add("name", "property.name"); input.Attributes.Add("id", "property_id"); // some classes for markup input.AddCssClass("btn btn-primary"); // equivalent to jQuery's $("property_id").text("Click me!"); input.InnerHtml = "Click me!"; However, wouldn’t it be nicer if we could say: ...

February 25, 2013 · 5 min · Alexander Moerman