<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Angle Bracket Percent</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/davidebb/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/davidebb/feed.xml</link>
    <description>David Ebbo&amp;#039;s blog
Follow me on Twitter (@davidebbo)</description>
    <lastBuildDate>Fri, 24 Jul 2015 08:35:10 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>This blog has moved!</title>
      <link>https://docs.microsoft.com/archive/blogs/davidebb/this-blog-has-moved</link>
      <pubDate>Sat, 01 Jan 2011 22:10:41 GMT</pubDate>
      <dc:creator><![CDATA[David Ebbo]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/davidebb/2011/01/01/this-blog-has-moved/</guid>
      <description><![CDATA[You can now find my blog at https://blog.davidebbo.com/, and all posts from now on will be...]]></description>
      <content:encoded><![CDATA[<p>You can now find my blog at <a href="https://blog.davidebbo.com/">https://blog.davidebbo.com/</a>, and all posts from now on will be there.&#160; Here is the <a href="https://blog.davidebbo.com/2010/12/new-year-new-blog.html">intro post</a> on the new blog.&#160; My feed goes through feedburner, so if you were subscribing to this blog before, you should now get updates from the new blog.&#160; See you over there!</p>]]></content:encoded>
    </item>
    <item>
      <title>An update on the NuGet package submission process</title>
      <link>https://docs.microsoft.com/archive/blogs/davidebb/an-update-on-the-nuget-package-submission-process</link>
      <pubDate>Sat, 25 Dec 2010 00:23:31 GMT</pubDate>
      <dc:creator><![CDATA[David Ebbo]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/davidebb/2010/12/25/an-update-on-the-nuget-package-submission-process/</guid>
      <description><![CDATA[If you’ve submitted a package to the NuGet feed, then you’re probably aware that our submission...]]></description>
      <content:encoded><![CDATA[<p>If you’ve submitted a package to the NuGet feed, then you’re probably aware that our <a href="https://nupackpackages.codeplex.com/">submission process</a> is not as good as it could be.&#160; Ok, this may be an understatement, so let’s go ahead and say it: it sucks!</p>  <h2></h2>  <p>With the current process, you have to clone a repository that has all the other packages, add your package files to it, and submit a pull request.&#160; Let’s first outline why this process is bad.</p>  <p>&#160;</p>  <h2>What’s wrong with the current process</h2>  <p><strong></strong></p>  <p><strong>Putting binaries in a DVCS is evil</strong>: DVCS like Mercurial work great for source code, but are atrocious for binary files.&#160; When you pull down the packages repository, you’re not just copying all the other packages’ binaries, but you’re copying down any binary that has ever existed in there.&#160; So whenever something is deleted or moved, we’re forever paying the price for that old binary.&#160; Bottom line: the repo has become very large, and cloning it is painful.</p>  <p><strong>It takes longer to get your packages live</strong>: after you send a pull request, you have to wait until it is accepted before your package can go live on the feed.&#160; This is frustrating, as you should be able to push packages nearly instantly.</p>  <p><strong>It makes *my* life difficult</strong>: somehow, I’m the sucker on the NuGet team who signed up for taking care of pull requests.&#160; While I got pretty good at it, it’s still time consuming given that rate at which they’ve been coming.&#160; And yes, there are other things I’d prefer to do with my time! <img style="border-bottom-style: none; border-right-style: none; border-top-style: none; border-left-style: none" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/38/88/metablogapi/2022.wlEmoticon-smile_147B48C5.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-38-88-metablogapi/2022.wlEmoticon_2D00_smile_5F00_147B48C5.png" /></p>  <p>&#160;</p>  <h2>Though it does have a couple advantages</h2>  <p><strong></strong></p>  <p><strong>I get to catch some package errors</strong>: if I see something that doesn’t look right, I can reject the pull request and tell the author to fix things.&#160; This results in a feed with less bad packages.&#160; Though better tools will allow this to become unnecessary.</p>  <p><strong>It allowed for global changes</strong>: since we have all the package pieces in one place, we were able to change everything at once when we made changes to the nuspec format, and this was very useful.&#160; But once 1.0 goes out (soon!), we will keep the format backward compatible, so this won’t be necessary.</p>  <p>&#160;</p>  <h2>If the process is bad, why did we choose to use it?</h2>  <p>&#160;</p>  <p>We really wanted to get NuGet out there as early as possible, and we just didn’t have a gallery ready.&#160; So we came up with this temporary process to get us going in the short term.&#160; As it turned out, it has lasted longer than we were hoping.&#160; Another factor is that you guys submitted way more packages than we were expecting.&#160; Though don’t get me wrong, we are <strong>very</strong> happy about that part!</p>  <p>So this little system that we expected would be used for a month or two and handle 50ish packages ended up being used quite a bit longer than it should have been, and on a feed that now has 312 packages.</p>  <p>&#160;</p>  <h2>So when will get better?</h2>  <p>&#160;</p>  <p>The good news is that we’ve made some good progress on our gallery, and it will soon be ready to go public.&#160; In fact, this gallery is being developed as open source, so there is absolutely nothing secret about it.&#160; You can find the source at <a href="https://orchardgallery.codeplex.com/">https://orchardgallery.codeplex.com/</a> and <a href="https://galleryserver.codeplex.com/">https://galleryserver.codeplex.com/</a> (it has a gallery piece and a backend piece).</p>  <p>With this new system, submitting a package will be as simple as building the nupkg file (using NuGet.exe), and uploading it to the gallery.&#160; It’s basically the same thing as uploading a VSIX to the Visual Studio extension gallery.&#160; The package will be live on the feed instantly.&#160; There is even a way to do this from the command line.</p>  <p>I don’t know exactly when this will go live, but it should be soon…</p>  <p>&#160;</p>  <h2>Now I’ll let you in on a little secret</h2>  <p>&#160;</p>  <p>The truth is that we are already using the new gallery!&#160; Some of you may have noticed that the fwlink now redirects to <a title="https://packages.nuget.org/GalleryServer/FeedService.svc" href="https://packages.nuget.org/GalleryServer/FeedService.svc">https://packages.nuget.org/GalleryServer/FeedService.svc</a>, while a week ago it went to <a title="https://feed.nuget.org/rtm/odata/v1/" href="https://feed.nuget.org/rtm/odata/v1/">https://feed.nuget.org/rtm/odata/v1/</a>.&#160; And this new link is in fact running the new gallery’s backend code (note that the URL will likely change again).</p>  <p>Also, when you submit new packages, I’m now submitting them to the new gallery using the command line tool.&#160; The part that’s not quite ready for prime time is the Orchard front end, which will let anyone create an account and submit packages.</p>  <p>But be patient, it’ll soon be ready!</p>]]></content:encoded>
    </item>
    <item>
      <title>Turn your Razor helpers into reusable libraries</title>
      <link>https://docs.microsoft.com/archive/blogs/davidebb/turn-your-razor-helpers-into-reusable-libraries</link>
      <pubDate>Wed, 27 Oct 2010 17:55:00 GMT</pubDate>
      <dc:creator><![CDATA[David Ebbo]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/davidebb/2010/10/27/turn-your-razor-helpers-into-reusable-libraries/</guid>
      <description><![CDATA[Note: the generator has evolved since this post. Although the post is still worth reading, please go...]]></description>
      <content:encoded><![CDATA[<p><b><span style="color: #ff0000;">Note: the generator has evolved since this post. Although the post is still worth reading, please go to&nbsp;<a href="https://razorgenerator.codeplex.com/">https://razorgenerator.codeplex.com/</a>&nbsp;for the most up to date doc.</span></b></p>
<p>The first blog post I ever wrote was titled &ldquo;<a href="https://blogs.msdn.com/b/davidebb/archive/2005/10/30/487160.aspx">Turning an ascx user control into a redistributable custom control</a>&rdquo;.&nbsp; It was almost exactly five years ago, and it still gets a lot of hits today.&nbsp; And interestingly, this new blog post is about solving essentially the same problem, but with a much nicer Razor based solution than was available at the time.</p>
<p>The general issue we&rsquo;re trying to solve is to encapsulate reusable pieces of UI.&nbsp; Unfortunately, this has typically meant choosing between two approaches, each having their pros and cons (this mirrors the intro from my old post):</p>
<ol>
<li><strong>Custom code</strong> in a library project: this makes it easy to produce a binary that can be used in multiple projects without having to keep source files around.&nbsp; But on the downside, it&rsquo;s painful to author rendering logic without a view engine language </li>
<li>Using a <strong>non-precompiled markup file</strong>: in the WebForms world, that meant an ascx file, while in the Razor world, it means a .cshtml file.&nbsp; This makes it easy to write rendering logic using ascx or Razor syntax.&nbsp; But the drawback is that it&rsquo;s hard to turn into a reusable library. </li>
</ol>
<p>Here, I will show you have you can have the best of both worlds in the Razor world: write your helpers using the powerful Razor declarative helpers syntax, while still being able to build them into a reusable library.</p>
<p>&nbsp;</p>
<h2>The quick &lsquo;getting started&rsquo; guide</h2>
<p>&nbsp;</p>
<p>If you don&rsquo;t care about the details of how this works and just want to use it, here is what you need to know to run it.</p>
<ul>
<li>Go to the VS Extension Gallery and install the Razor Single File Generator. </li>
</ul>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/38/88/metablogapi/3618.image_00E2E944.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-38-88-metablogapi/3618.image_5F00_00E2E944.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/38/88/metablogapi/2146.image_thumb_66069D6A.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-38-88-metablogapi/2146.image_5F00_thumb_5F00_66069D6A.png" width="571" height="274" /></a></p>
<p>&nbsp;</p>
<ul>
<li>Here you may need to restart VS</li>
<li>In a Library project, create a Razor file (.cshtml extension) </li>
<li>Under its properties, set the Build Action to None, and set the custom tool to RazorClassGenerator </li>
</ul>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/38/88/metablogapi/2158.image_25D083F0.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-38-88-metablogapi/2158.image_5F00_25D083F0.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/38/88/metablogapi/6443.image_thumb_33A2C9EB.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-38-88-metablogapi/6443.image_5F00_thumb_5F00_33A2C9EB.png" width="326" height="172" /></a></p>
<ul>
<li>Define various @helper methods in the cshtml file.&nbsp; When you save it, it&rsquo;ll produce a nested .cs file, e.g. </li>
</ul>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/38/88/metablogapi/7024.image_5A70E02B.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-38-88-metablogapi/7024.image_5F00_5A70E02B.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/38/88/metablogapi/1651.image_thumb_5351A3B3.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-38-88-metablogapi/1651.image_5F00_thumb_5F00_5351A3B3.png" width="219" height="93" /></a></p>
<ul>
<li>Reference the library from your Razor view (in an MVC3 or Web Pages app) and use the helpers! </li>
</ul>
<p>And if you&rsquo;re looking for the source code, it&rsquo;s all on CodePlex:&nbsp;<a href="https://razorgenerator.codeplex.com/">https://razorgenerator.codeplex.com/</a></p>
<h2>&nbsp;</h2>
<h2>What are Razor declarative helpers?</h2>
<p>&nbsp;</p>
<p>Scottgu introduced the concept in his <a href="https://weblogs.asp.net/scottgu/archive/2010/07/02/introducing-razor.aspx">Razor post</a>, under the &ldquo;Declarative HTML Helpers&rdquo; section.&nbsp; Here is an example:</p>
<pre class="brush: xml;">@helper WriteList(string[] items) {
    &lt;ul&gt;
        @foreach (var s in items) {
            &lt;li&gt;
                @s
            &lt;/li&gt;
        }
    &lt;/ul&gt;
}</pre>
<p>
Here, we are using the powerful Razor syntax to define what our helper will output.&nbsp; The code in the method is basically the same thing as you write in regular Razor rendering logic, but the fact that it&rsquo;s inside an @helper method turns it into a declarative helper. 
</p>
<p>Normally, those @helper methods must live either in your view itself, or in a .cshtml file in App_Code.&nbsp; When it&rsquo;s in the view itself, it&rsquo;s only usable within that one view, while when it&rsquo;s in App_Code, it&rsquo;s usable from anywhere in your app.&nbsp; But in either case, it really isn&rsquo;t very reusable in the sense that you can&rsquo;t easily turn it into a library of helpers that you can use in any app without having to carry the .cshtml file.</p>
<p>&nbsp;</p>
<h2>A VS Single File Generator to the rescue</h2>
<p>&nbsp;</p>
<p>If you&rsquo;ve ever used T4 (which I&rsquo;ve blogged quite a bit about), then you pretty much know what a Single File Generator is.&nbsp; It&rsquo;s something that you can attach to a file in your project, such that it generates another file underneath it.</p>
<p>In this case, the file we attach a SingleFileGenerator to is the .cshtml file, and what it generates is the source code that the Razor engine produces from it.</p>
<p>Writing a VS Single File Generator may seem scary, but luckily there is a good sample in the SDK: <a title="https://code.msdn.microsoft.com/sfgdd" href="https://code.msdn.microsoft.com/sfgdd">https://code.msdn.microsoft.com/sfgdd</a>.&nbsp; In fact, most of the code in my Razor generator is directly copied from this.&nbsp; The only place that has interesting code that&rsquo;s specific to Razor is the RazorClassGenerator.GenerateCode() method.&nbsp; Here is the key code (simplified for brevity):</p>
<pre class="brush: csharp;">// Determine the project-relative path
string projectRelativePath = InputFilePath.Substring(appRoot.Length);

// Turn it into a virtual path by prepending ~ and fixing it up
string virtualPath = VirtualPathUtility.ToAppRelative("~" + projectRelativePath);

// Create the same type of Razor host that's used to process Razor files in App_Code
var host = new WebCodeRazorHost(virtualPath, InputFilePath);

// Set the namespace to be the same as what's used by default for regular .cs files
host.DefaultNamespace = FileNameSpace;

// Create a Razor engine nad pass it our host
var engine = new RazorTemplateEngine(host);

// Generate code
GeneratorResults results = null;
using (TextReader reader = new StringReader(inputFileContent)) {
    results = engine.GenerateCode(reader);
}

// Then results.GeneratedCode has the CodeDom CodeCompileUnit that the generator needs</pre>
<p>
So it&rsquo;s all pretty simple.&nbsp; In essence, all it does is give the content of the Razor file to the Razor engine and asks it to generate the right code for it. 
</p>
<p>&nbsp;</p>
<h2>Possible areas of improvement</h2>
<p>&nbsp;</p>
<p>The most obvious pain point when using this is that you need to manually set the custom tool to RazorClassGenerator.&nbsp; It should be relatively easy to add behavior to the VSIX that would add a right click option on .cshtml files that would set this up.</p>
<p>Another potentially very cool thing is to not only use this to precompile @helpers, but also real Views.&nbsp; This is trickier because it requires some logic that will allow the view engine to find the precompiled Views, but it can certainly be done.</p>]]></content:encoded>
    </item>
    <item>
      <title>Light up your NuGets with startup code and WebActivator</title>
      <link>https://docs.microsoft.com/archive/blogs/davidebb/light-up-your-nugets-with-startup-code-and-webactivator</link>
      <pubDate>Mon, 11 Oct 2010 01:52:00 GMT</pubDate>
      <dc:creator><![CDATA[David Ebbo]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/davidebb/2010/10/11/light-up-your-nugets-with-startup-code-and-webactivator/</guid>
      <description><![CDATA[[Please see the&nbsp;WebActivator wiki&nbsp;for the latest docs]
Wow, it&rsquo;s hard to believe...]]></description>
      <content:encoded><![CDATA[<p><b>[Please see the&nbsp;<a href="https://bitbucket.org/davidebbo/webactivator/wiki/Home">WebActivator wiki</a>&nbsp;for the latest docs]</b></p>
<p>Wow, it&rsquo;s hard to believe that it&rsquo;s been less than a week since NuGet went public.&nbsp; We were hoping to get noticed, but the attention we got was way beyond my wildest expectations!&nbsp; The buzz on Twitter has just been phenomenal, and for the most part the feedback has been very positive.&nbsp; Thank you all for that, this is very encouraging for our little NuGet team :)</p>
<p>&nbsp;</p>
<h2>Going beyond assembly references</h2>
<p>&nbsp;</p>
<p>The most common type of NuGet packages bring in assembly references into a project.&nbsp; It&rsquo;s super useful, because it saves you from finding it, downloading it, adding the reference, getting dependencies and dealing with versioning.&nbsp; If NuGet didn&rsquo;t do any more than that, I think it could be very successful, because that is such a core step that gets repeated manually so many times by so many people.</p>
<p>But it can in fact do a lot more than that!&nbsp; The first thing that you probably saw already is the config transform support.&nbsp; I demoed that in my earlier <a href="https://www.youtube.com/watch?v=6FKJ2Au27gQ">screencast</a> and various people blogged it, with the ELMAH package adding a bunch of things to web.config to make things work.</p>
<p>But not everything that configures libraries goes through web.config.&nbsp; Thankfully, many libraries come with a code driven way of setting things up (I personally much prefer that over config).&nbsp; A good example is Louis DeJardin&rsquo;s <a href="https://sparkviewengine.com/">Spark View Engine</a>.&nbsp; In order to use it in an ASP.NET MVC application, you need to create a SparkSettings instance, configure it, feed it to a SparkViewFactory, and then register it as a View Engine with MVC.&nbsp; Pretty painful steps if you&rsquo;ve not done it before and just want to get started with Spark.&nbsp; See Step 5 in <a href="https://aleris.wordpress.com/2009/03/29/adding-spark-view-engine-to-aspnet-mvc-a-step-by-step-guide/">this page</a> for an example of what I&rsquo;m referring to.</p>
<p>So what can NuGet do to make your life easier in these scenarios?&nbsp; Quite simply, NuGets can include some source code that ends up as part of the project.&nbsp; For instance, if you install the SparkMvc package, you&rsquo;ll notice a file named SparkMvc.cs under the App_Start folder, which contains this set up code.&nbsp; How did the package pull that trick?&nbsp; Very easy: all it needs to do is include a file named SparkMvc.cs<strong>.pp</strong> in its Content\App_Start folder.&nbsp; The reason it has an extra .pp extension is to indicate that it should be preprocessed, which allows it to end up in the correct namespace. &nbsp;SparkMvc.cs.pp contains (omitting one magic line that I&rsquo;ll discuss later!):</p>
<pre class="brush: csharp;">using System.Web.Mvc;
using Spark;
using Spark.Web.Mvc;

// Secret line goes here! :)

namespace $rootnamespace$.App_Start {
    public static class SparkMvc {
        public static void Start() {
            var settings = new SparkSettings();

            // comment this if you want to use Html helpers with the ${} syntax:
            // otherwise you would need to use the &lt;%= %&gt; syntax with anything that outputs html code
            settings.SetAutomaticEncoding(true); 

            settings
                .AddNamespace("System")
                .AddNamespace("System.Collections.Generic")
                .AddNamespace("System.Linq")
                .AddNamespace("System.Web.Mvc")
                .AddNamespace("System.Web.Mvc.Html");
                // Add here more namespaces to your model classes
                // or whatever classes you need to use in the views

            settings
                .AddAssembly("Spark.Web.Mvc")
                .AddAssembly("System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35")
                .AddAssembly("System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");

            ViewEngines.Engines.Add(new SparkViewFactory(settings));
        }
    }
}</pre>
<p>So the only funny business here is the $rootnamespace$ token, which gets replaced by the namespace of the target project (as in Item Templates).&nbsp; Other than that, it&rsquo;s just a static method that contains all the Spark set up logic, which you can of course freely modify once it&rsquo;s in your app.&nbsp; It&rsquo;s just starter code to get you on the right path.</p>
<p>Finally, you&rsquo;d need to go in your global.asax&rsquo;s Application_Start and add a line to call this static method.&nbsp; That works, but that&rsquo;s kind of a lame manual step that you always have to take after installing the package.&nbsp; But wait, maybe you don&rsquo;t have to!</p>
<p>&nbsp;</p>
<h2>Enter WebActivator</h2>
<p>&nbsp;</p>
<p>Luckily, there is a very simple way to avoid forcing the package&rsquo;s user to manually call the startup code from global.asax.&nbsp; And this mechanism is not provided by the NuGet engine itself, but comes simply as a result of taking a dependency on a little NuGet called WebActivator.&nbsp; If you look for at the .nuspec manifest file for SparkMvc, you&rsquo;ll see something like:</p>
<pre class="brush: xml;">  &lt;dependencies&gt;
    &lt;dependency id="spark" minversion="1.0" /&gt;
    &lt;dependency id="WebActivator" version="1.0.0.0" /&gt;
  &lt;/dependencies&gt;</pre>
<p>Note that in addition to having a dependency on Spark core, it has a dependency on the WebActivator NuGet.&nbsp; So what exactly does that do?&nbsp; It lets you write the secret magic line that I omitted in the code above:</p>
<pre class="brush: csharp;">using System.Web.Mvc;
using Spark;
using Spark.Web.Mvc;

[assembly: WebActivator.PreApplicationStartMethod(typeof($rootnamespace$.App_Start.SparkMvc), "Start")]<br />
namespace $rootnamespace$.App_Start {
    public static class SparkMvc {
        public static void Start() {
            // etc...</pre>
<p>&nbsp;</p>
<p>So WebActivator lets you define a PreApplicationStartMethod attribute which is used to mark your method as something that gets called when the Web app starts.&nbsp; And that&rsquo;s it!&nbsp; Now when you install the SparkMvc NuGet in your app, Spark is completely ready to go, and you just need to add your spark views.</p>
<p>Note: the sources for WebActivator are on <a href="https://bitbucket.org/davidebbo/webactivator">bitbucket</a>.</p>
<p>&nbsp;</p>
<h2>Hey, this attribute looks familiar!</h2>
<p>&nbsp;</p>
<p>If the PreApplicationStartMethod attribute looks familiar, it&rsquo;s because ASP.NET 4.0 actually comes with one named exactly the same, and that does the exact same thing (Phil Haack did a nice <a href="https://haacked.com/archive/2010/05/16/three-hidden-extensibility-gems-in-asp-net-4.aspx">post</a> on it).&nbsp; So why the heck aren&rsquo;t we using it instead of coming up with a new one named the same and that does the same thing?!&nbsp; The reason is that we were short sighted when we designed this feature in ASP.NET, and only allowed this attribute to be used once per assembly.&nbsp; This works fine for scenarios where you own the whole assembly, but fails terribly for our NuGet scenario where we want unrelated packages to each come with their startup logic.&nbsp; ASP.NET fail!&nbsp; Wait, I was involved in that feature :(</p>
<p>So the idea is that we can use WebActivator for now, and then we&rsquo;ll make the ASP.NET attribute more flexible in a future release, at which point WebActivator will not be needed as a separate thing (that&rsquo;s just a tentative plan, it&rsquo;s not settled yet).&nbsp; But until then, WebActivator does the job nicely, and using it is as easy as adding one dependency line in your .nuspec file, so we&rsquo;re not in a bad place. :)</p>
<p>&nbsp;</p>
<h2>Update (2/15/2011): new switch to have method be called <i>after</i> global.asax App_Start</h2>
<p>&nbsp;</p>
<p>In some scenarios, the pre app start method gets called too early, as it happens before global.asax. In WebActivator 1.3, I added support for a new attribute that makes the method be called after global.asax's Application_Start. To use this, simply use PostApplicationStartMethod instead of PreApplicationStartMethod, e.g.</p>
<p>&nbsp;</p>
<pre class="brush: csharp;">[assembly: WebActivator.PostApplicationStartMethod(typeof(TestLibrary.MyStartupCode), "CallMeAfterAppStart")]</pre>
<p>&nbsp;</p>
<p>What this does is register a module (using <a href="https://blog.davidebbo.com/2011/02/register-your-http-modules-at-runtime.html">this technique</a>), and then call your method the first time an instance of the module's Init is called. Note that your method will only be called once even though the module can get instantiated multiple times. So the fact that it uses a module should mostly just be an implementation detail. What matters is that you method will get called later than&nbsp;Application_Start (but still very early in the appdomain start up sequence).</p>
<p>&nbsp;</p>
<h2>Other NuGets that use WebActivator</h2>
<p>&nbsp;</p>
<p>Here is the current list of NuGets that make use of this mechanism:</p>
<ul>
<li><strong>Spark.Web.Mvc3</strong>, as discussed here </li>
<li><strong>Ninject.MVC3</strong> uses it to register the Ninject DI Container with ASP.NET MVC (new MVC3 feature, see Brad Wilson&rsquo;s <a href="https://bradwilson.typepad.com/blog/2010/10/service-location-pt5-idependencyresolver.html">post</a>!) </li>
<li><strong>EFCodeFirst.SqlServerCompact</strong>&nbsp;uses it to make the EF CTP4 bits use SQLCE 4 </li>
<li>51Degrees.mobi</li>
<li>AddMvc3ToWebForms</li>
<li>AttributeRouting</li>
<li>Combres</li>
<li>DataAnnotationsExtensions.MVC3</li>
<li>entile-server</li>
<li>FubuMVC</li>
<li>MefContrib.MVC3</li>
<li>NuGet.Server</li>
<li>RestfulRouting</li>
<li>SimpleMembership.Mvc3</li>
<li>StructureMap-MVC3</li>
<li>VirtualPathTemplates</li>
</ul>
<p>And I&rsquo;m sure more will come!&nbsp; Pretty much any NuGet that needs to execute startup code should make use of this.</p>
<p>&nbsp;</p>
<h2>Feedback welcome</h2>
<p>&nbsp;</p>
<p>WebActivator is still very new, and I&rsquo;d love to hear feedback about it from NuGet users.&nbsp; You can leave a comment here, or start a discussion on <a href="https://nuget.codeplex.com/">https://nuget.codeplex.com/</a>.&nbsp; The latter is probably best as it makes it easier to have a discussion among many folks.</p>]]></content:encoded>
    </item>
    <item>
      <title>Introducing NuGet: the smart way to bring bits into your projects</title>
      <link>https://docs.microsoft.com/archive/blogs/davidebb/introducing-nuget-the-smart-way-to-bring-bits-into-your-projects</link>
      <pubDate>Tue, 05 Oct 2010 18:48:26 GMT</pubDate>
      <dc:creator><![CDATA[David Ebbo]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/davidebb/2010/10/05/introducing-nuget-the-smart-way-to-bring-bits-into-your-projects/</guid>
      <description><![CDATA[I’m thrilled to announce that the secret project we’ve been working on for the last few months is no...]]></description>
      <content:encoded><![CDATA[<p>I’m thrilled to announce that the secret project we’ve been working on for the last few months is no longer a secret!&#160; It’s called NuGet, and you can download it from <a href="https://nupack.codeplex.com/releases/view/52016">here</a>.&#160; Make sure you also read <a href="https://weblogs.asp.net/scottgu/archive/2010/10/06/announcing-nupack-asp-net-mvc-3-beta-and-webmatrix-beta-2.aspx">ScottGu’s post</a> about it.</p>  <p>So what the heck is NuGet?&#160; In short, it’s an Open Source package manager that lets you import libraries into your .NET applications with much less effort than what you’re used to.&#160; Note that NuGet is not a Microsoft project, but an <a href="https://www.outercurve.org/News/articleType/ArticleView/articleId/20/Outercurve-Foundation-Announces-NuPack-as-Fifth-Project-in-ASPNET-Open-Source-Gallery">Outercurve Foundation project</a> (previously Codeplex Foundation).&#160; It has both Microsoft and non-Microsoft contributors, and is run as a true Open Source project.&#160; See <a href="https://nuget.codeplex.com/">https://nuget.codeplex.com/</a> for more info on this.</p>  <p>&#160;</p>  <h2>What problem is NuGet solving exactly?</h2>  <p>&#160;</p>  <p>If you’re a .NET programmer, you’ve likely experienced the pain of getting a 3rd party library into your project.&#160; It usually goes something like this:</p>  <ol>   <li>You know what it’s called, but you have no idea where it lives, so you search for it in your favorite engine.&#160; You often find multiple pages that could legitimately be the want you want. </li>    <li>You look around the main page for a link to the download page. </li>    <li>Once on the download page, you’re often presented with way more choices than you’d like: several builds, for several platforms, … </li>    <li>You download a zip file that you then unzip somewhere on your machine (after remembering to ‘unblock’ it in Windows!). </li>    <li>You copy the relevant assemblies into some folder in your solution. </li>    <li>In VS, you add a reference to the assemblies. </li>    <li>In some cases, you need to make changes to your web.config file to properly enable the component.&#160; This is quite non-trivial if you’re not familiar with it. </li> </ol>  <p>Needless to say, all of that is pretty painful and error prone.&#160; Sure, once you’re familiar with a library, you’d probably just copy it from another project instead of getting it from the web, which makes things a bit easier.&#160; But it’s still an overall very ad-hoc process.</p>  <p>And that doesn’t even cover the common case where a library has a dependency on some other libraries, which raises the complexity to the next level.</p>  <p>&#160;</p>  <h2>NuGet to the rescue!</h2>  <p>&#160;</p>  <p>With NuGet, you get a PowerShell window directly in Visual Studio.&#160; You just type a simple command like ‘Add-Package CoolLibrary’, and it takes care of everything.&#160; You can also right click on References and choose ‘Add Package Reference’ to do the same thing through a dialog.&#160; It’s all very very easy, and it just works!</p>  <p>But instead of giving you all the details in writing, I put together a screen cast that shows NuGet in action!&#160; It’s 14 minutes long, so a little bit on the long side, but it demonstrates using NuGet to install all kind of libraries into an MVC 3 app, so it’s pretty action pack.&#160; If that doesn’t convince you of the awesomeness of NuGet, then I will have failed :)</p>  <p>Note: to watch it optimally, you can click on it a second time to view it directly in YouTube.&#160; In there, change it to 720p and play it in full screen.</p>  <p>Another small note is that I made this video with a slightly older build, so you will see some small UI differences with the public bits.</p>  <p>&#160;</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:c3b8ab1e-3a04-4ef3-b055-c27843ce9149" class="wlWriterSmartContent">   <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px" id="353b1f48-a740-4dad-bdcf-c5558f953182">     <div><a href="https://www.youtube.com/watch?v=6FKJ2Au27gQ&amp;feature=youtube_gdata_player" target="_new"><img style="border-bottom-style: none; border-right-style: none; border-top-style: none; border-left-style: none" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/38/88/metablogapi/5224.video1b1a3c53cf27.jpg" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-38-88-metablogapi/5224.video1b1a3c53cf27.jpg" onload="var downlevelDiv = document.getElementById(&#39;353b1f48-a740-4dad-bdcf-c5558f953182&#39;); downlevelDiv.innerHTML = &quot;&lt;div&gt;&lt;object width=\&quot;448\&quot; height=\&quot;252\&quot;&gt;&lt;param name=\&quot;movie\&quot; value=\&quot;https://www.youtube.com/v/6FKJ2Au27gQ?hl=en&amp;hd=1\&quot;&gt;&lt;\/param&gt;&lt;embed src=\&quot;https://www.youtube.com/v/6FKJ2Au27gQ?hl=en&amp;hd=1\&quot; type=\&quot;application/x-shockwave-flash\&quot; width=\&quot;448\&quot; height=\&quot;252\&quot;&gt;&lt;\/embed&gt;&lt;\/object&gt;&lt;\/div&gt;&quot;;" galleryimg="no" /></a></div>   </div>    <div style="width: 448px; clear: both; font-size: 0.8em">NuPack in Action</div> </div>  <p>&#160;</p>  <p>I’ll be blogging some more about NuGet in the coming days, so stay tuned!</p>]]></content:encoded>
    </item>
    <item>
      <title>The easy way to create an Entity Framework ‘Defining Query’</title>
      <link>https://docs.microsoft.com/archive/blogs/davidebb/the-easy-way-to-create-an-entity-framework-defining-query</link>
      <pubDate>Fri, 01 Oct 2010 14:33:00 GMT</pubDate>
      <dc:creator><![CDATA[David Ebbo]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/davidebb/2010/10/01/the-easy-way-to-create-an-entity-framework-defining-query/</guid>
      <description><![CDATA[Entity Framework supports a concept called a &lsquo;Defining Query&rsquo;, which is basically a...]]></description>
      <content:encoded><![CDATA[<p>Entity Framework supports a concept called a &lsquo;Defining Query&rsquo;, which is basically a client side database View.&nbsp; I only learned about that feature a few days ago, and I thought I&rsquo;d share some tips about how to create them in a way that&rsquo;s much easier than anything I could find out there.</p>
<p>The first thing you need to know is that there is no Designer Support for using this feature, and that means you have to be prepared to edit your .edmx file as XML.&nbsp; If this sounds too scary, stop here! :)&nbsp; The difference is that the technique I found lets you make extremely simple changes, whereas the &lsquo;standard&rsquo; technique is plain scary.</p>
<p>So let&rsquo;s take a quick look at the standard technique, which is <a href="https://msdn.microsoft.com/en-us/library/cc982038.aspx">explained on MSDN</a>.&nbsp; Basically, you have to add a <strong>ton</strong> of XML in many different places, and I personally wouldn&rsquo;t want to do this by hand.&nbsp; With my &lsquo;trick&rsquo;, you don&rsquo;t need to change any XML.&nbsp; All you have to do is paste your SQL query in there.</p>
<p>So what exactly is my trick?&nbsp; It relies on temporarily creating a real database View (i.e. a server view), and have that drive all the XML creation for you!&nbsp; Here are the basic steps:</p>
<ol>
<li>Create a regular SQL View </li>
<li>Map it into the EF model using the designer </li>
<li>Copy the SQL View&rsquo;s query, and paste it into the SSDL&rsquo;s &lt;DefiningQuery&gt; tag, replacing the query that&rsquo;s there! </li>
<li>Now you can delete the SQL View </li>
</ol>
<p>&nbsp;</p>
<h2>A step by step example using everyone&rsquo;s favorite database</h2>
<p><em></em></p>
<p><em>Note: the sample is available on </em><a href="https://bitbucket.org/davidebbo/entityframeworkdefiningquery"><em>BitBucket</em></a><em>.</em></p>
<p>&nbsp;</p>
<p>So let&rsquo;s say our goal is to create a Defining Query for Northwind called ProductsWithCategoryName, which returns products along with the name of the category they&rsquo;re in.</p>
<h3>Step 0: setting things up</h3>
<p>Not really a step, but let&rsquo;s assume that you already have some app (could be a console app) that has imported Northwind, so you&rsquo;re able to go in Server Explorer and see the Tables, &hellip;</p>
<p>&nbsp;</p>
<h3>Step 1: Creating a real SQL View</h3>
<p>So even though our goal is to create a Defining Query, we&rsquo;ll create a real SQL view here (we&rsquo;ll delete it later).&nbsp; So let&rsquo;s create our simple View:</p>
<ul>
<li>Right click on Views / Add New View </li>
<li>In the Add Tables dialog, pick both Products &amp; Categories and click Add.&nbsp; It&rsquo;s smart enough to guess that you want to use an INNER JOIN here. </li>
<li>Click the columns that you care about.&nbsp; e.g. let&rsquo;s pick ProductID, ProductName and UnitsInStock from the Products table, and CategoryName from the Categories table. </li>
</ul>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/38/88/metablogapi/1033.image_2.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-38-88-metablogapi/1033.image_5F00_2.png"><img height="247" width="406" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/38/88/metablogapi/4670.image_thumb.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-38-88-metablogapi/4670.image_5F00_thumb.png" alt="image" border="0" title="image" style="background-image: none; border-right-width: 0px; margin: 5px 5px 5px 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" /></a></p>
<p>This automatically creates the View&rsquo;s query for you, so you don&rsquo;t actually need to know any SQL.&nbsp; Your query should look like this:</p>
<pre class="brush: csharp;">SELECT        dbo.Products.ProductID, dbo.Products.ProductName, dbo.Products.UnitsInStock, dbo.Categories.CategoryName
FROM            dbo.Categories INNER JOIN
                         dbo.Products ON dbo.Categories.CategoryID = dbo.Products.CategoryID</pre>
<ul>
<li>Save that query in your clipboard, you&rsquo;ll need it soon! </li>
<li>Now just save the View as &lsquo;ProductsWithCategoryName&rsquo; </li>
</ul>
<p>&nbsp;</p>
<h3>Step 2: Import the view in an EF model</h3>
<p>&nbsp;</p>
<p>So far, we haven&rsquo;t touch EF.&nbsp; Now is the time!</p>
<ul>
<li>In your project, add a new &ldquo;ADO.NET entity data model&rdquo; </li>
<li>Choose Generate From Database, and pick your Northwind </li>
<li>When you get to &lsquo;Choose Your Database Objects&rsquo;, pick your ProductsWithCategoryName View.&nbsp; You can also include other things if you want. </li>
</ul>
<p>&nbsp;</p>
<h3>Step 3: paste your query in the edmx file</h3>
<p>&nbsp;</p>
<p>This is the step!&nbsp; The one that we actually start talking about your &lsquo;defining query&rsquo;.</p>
<ul>
<li>First you&rsquo;ll need to open your edmx as XML: right click it, Open With, and choose Automatic XML.&nbsp; In there, near the top , you should see something like this: </li>
</ul>
<pre class="brush: xml;">&lt;EntitySet Name="ProductsWithCategoryName" EntityType="NorthwindModel.Store.ProductsWithCategoryName" store:Type="Views" store:Schema="dbo" store:Name="ProductsWithCategoryName"&gt;
  &lt;DefiningQuery&gt;
      SELECT
      [ProductsWithCategoryName].[ProductID] AS [ProductID],
      [ProductsWithCategoryName].[ProductName] AS [ProductName],
      [ProductsWithCategoryName].[UnitsInStock] AS [UnitsInStock],
      [ProductsWithCategoryName].[CategoryName] AS [CategoryName]
      FROM [dbo].[ProductsWithCategoryName] AS [ProductsWithCategoryName]
  &lt;/DefiningQuery&gt;
&lt;/EntitySet&gt;</pre>
<p>
It already has a DefiningQuery, but it&rsquo;s defined in term of your server View, which is no good since we plan to get rid of that view!&nbsp; So simply paste the query you copied in step 1 on top of it.&nbsp; You now have: 
</p>
<pre class="brush: xml;">&lt;EntitySet Name="ProductsWithCategoryName" EntityType="NorthwindModel.Store.ProductsWithCategoryName" store:Type="Views" store:Schema="dbo" store:Name="ProductsWithCategoryName"&gt;
  &lt;DefiningQuery&gt;
      SELECT        dbo.Products.ProductID, dbo.Products.ProductName, dbo.Products.UnitsInStock, dbo.Categories.CategoryName
      FROM            dbo.Categories INNER JOIN
      dbo.Products ON dbo.Categories.CategoryID = dbo.Products.CategoryID
  &lt;/DefiningQuery&gt;
&lt;/EntitySet&gt;</pre>
<p>And that&rsquo;s it!&nbsp; If you look down in the edmx, you&rsquo;ll see that all the other scary things that the <a href="https://msdn.microsoft.com/en-us/library/cc982038.aspx">MSDN article</a> tells you to create by hand are already there!&nbsp; This happened for free because your SQL View (which the designer <strong>does </strong>support) has the exact same structure as your &lsquo;Defining Query&rsquo;.</p>
<p>&nbsp;</p>
<h3>Step 4: delete the SQL View</h3>
<p>&nbsp;</p>
<p>The SQL view we created in step 1 has served its purpose, so you can delete it if you want.&nbsp; Even though it has done all the hard work for you, and asked for nothing in return.&nbsp; Go ahead, delete it! :)</p>
<p>&nbsp;</p>
<h3>Using the defining query in your code</h3>
<p>&nbsp;</p>
<p>Now you can just use your Defining Query in your code as you would if it were a regular View.&nbsp; e.g.</p>
<pre class="brush: csharp;">static void Main(string[] args) {
    var context  = new NorthwindEntities();
    foreach (var p in context.ProductsWithCategoryNames) {
        Console.WriteLine(String.Format("{0} / {1} / {2}", p.ProductName, p.CategoryName, p.UnitsInStock));
    }
}</pre>
<p>One caveat you need to be aware of is that since the designer doesn&rsquo;t support defining queries, it won&rsquo;t preserve your change if you re-save the edmx through the designer.&nbsp; Apparently, they&rsquo;re planning to fix that.</p>
<p>Anyway, that was my little contribution to the Entity Framework world&hellip;</p>]]></content:encoded>
    </item>
    <item>
      <title>A short take on Microsoft.Data</title>
      <link>https://docs.microsoft.com/archive/blogs/davidebb/a-short-take-on-microsoft-data</link>
      <pubDate>Tue, 03 Aug 2010 10:24:50 GMT</pubDate>
      <dc:creator><![CDATA[David Ebbo]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/davidebb/2010/08/03/a-short-take-on-microsoft-data/</guid>
      <description><![CDATA[Yesterday, David Fowler blogged about the Microsoft.Data APIs that come with ASP.NET...]]></description>
      <content:encoded><![CDATA[<p>Yesterday, David Fowler <a href="https://weblogs.asp.net/davidfowler/archive/2010/08/02/introduction-to-microsoft-data-dll.aspx">blogged</a> about the Microsoft.Data APIs that come with <a href="https://weblogs.asp.net/scottgu/archive/2010/07/06/introducing-webmatrix.aspx">ASP.NET WebMatrix</a>.&#160; While there were some positive comments, the majority were negative.&#160; The reason for that is that a lot of readers completely missed the point of the API.&#160; David is partially to blame for that, as he had not properly put it into context.&#160; He since wrote a <a href="https://weblogs.asp.net/davidfowler/archive/2010/08/03/microsoft-data-dll-a-re-introduction.aspx">follow up post</a> which fills in those gaps (and here is <a href="https://blog.andrewnurse.net/2010/08/03/MicrosoftDataItrsquosNotAsEvilAsYouThink.aspx">another one</a> by Andrew Nurse), but I’ll try to do a slightly different take on this.</p>  <p>So in what sense did some readers ‘miss the point’?&#160; They read it as:</p>  <blockquote>   <p><em>Microsoft is now recommending a new data API.&#160; That API uses raw SQL rather than an ORM.&#160; Bunch of Microsoft idiots, what are they thinking!? :)</em></p> </blockquote>  <p>The reality is of course quite different.&#160; As great as ORMs are, there is a measurable number of web developers who favor writing raw SQL over using an ORM.&#160; That is a fact, and if you’re trying to pretend that it is not the case, you’re in denial.&#160; Though they tend to be less vocal, there are a lot of people who prefer the raw SQL approach, for a variety of reasons.&#160; But the point of this post is not about whether one should use an ORM vs raw SQL, as enough blood has been poured over that. :)</p>  <p>Instead, this post is about this new Microsoft.Data API.&#160; Here is a one liner that describes its goal:</p>  <blockquote>   <p><em><font style="background-color: #ffff00"><strong>Given that someone will use raw SQL</strong></font>, how can we make it easier.</em></p> </blockquote>  <p>The first part of the sentence is key, and is what makes all the comments along the lines of “<em>they should not use raw SQL because …</em>” completely moot.&#160; Simply put, if you are an ORM user this technology is not for you.</p>  <p>Instead, the only relevant way to look at this API is to discuss whether it is indeed an improvement over the old ADO.NET API.&#160; And in my opinion that is no brainer.&#160; Pretty much everyone who has seen it in this light has agreed.&#160; Among the advantages over ‘classic’ ADO.NET:</p>  <ul>   <li>It uses far fewer concepts to achieve the same things.&#160; Having to deal with SqlConnection/SqlCommand/SqlDataReader can be overwhelming. </li>    <li>It makes it easier to use parameterized queries, hence reducing the risks of SQL injection issues (<a href="https://blog.andrewnurse.net/2010/08/03/MicrosoftDataItrsquosNotAsEvilAsYouThink.aspx">Andrew’s post</a> has some simple examples). </li>    <li>It uses ‘dynamic’ to make it more natural to access row values. </li> </ul>  <p>Is it revolutionary compared to classic ADO.NET?&#160; Clearly not, and no one claims that!&#160; But it is a long overdue simplification to the messy ADO.NET APIs, and in that sense it is pure goodness.</p>  <p>Now you can get back to your favorite ORM and feel safe that your world is not under assault. :)</p>]]></content:encoded>
    </item>
    <item>
      <title>T4MVC 2.6.20, and upcoming T4MVC talk at MvcConf</title>
      <link>https://docs.microsoft.com/archive/blogs/davidebb/t4mvc-2-6-20-and-upcoming-t4mvc-talk-at-mvcconf</link>
      <pubDate>Tue, 20 Jul 2010 00:28:11 GMT</pubDate>
      <dc:creator><![CDATA[David Ebbo]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/davidebb/2010/07/20/t4mvc-2-6-20-and-upcoming-t4mvc-talk-at-mvcconf/</guid>
      <description><![CDATA[I just pushed T4MVC out to the MvcContrib CodePlex site.&#160; You can go to the T4MVC Home Page to...]]></description>
      <content:encoded><![CDATA[<p>I just pushed T4MVC out to the MvcContrib CodePlex site.&#160; You can go to the <a href="https://mvccontrib.codeplex.com/wikipage?title=T4MVC">T4MVC Home Page</a> to get started with it.</p>  <p>Last time I blogged about a T4MVC release was for 2.6.13.&#160; In the mean time, I released 2.6.14 and 2.6.15, but they were minor updates so I just tweeted them.&#160; You can check out the <a href="https://mvccontrib.codeplex.com/wikipage?title=T4MVC_History">history page</a> to see what they changed.&#160; Now, 2.5.20 brings a more interesting new feature, so I figured I’d blog it.</p>  <h2>New feature to easily render Partials</h2>  <p>&#160;</p>  <p><em><strong>Update (7/20/2010)</strong>: there was a small issue with this change when multiple ascx have the same name.&#160; I just pushed a new 2.6.21 build which addresses it.</em></p>  <p>This new feature was written by <a href="https://twitter.com/weirdmvc">Evan Nagle</a> (who is also the author of the <a href="https://chirpy.codeplex.com/">Chirpy add-in</a> I <a href="https://blogs.msdn.com/b/davidebb/archive/2010/07/17/check-out-chirpy-a-very-cool-add-in-to-run-t4mvc-and-do-many-other-cool-things.aspx">discussed</a> a few days ago).&#160; You can check out the <a href="https://www.weirdlover.com/2010/05/12/t4mvc-extension-for-mvc-partials/">post</a> he wrote about it.&#160; In a nutshell, it’s about making it easier to render partial pages.&#160; e.g. suppose you have a partial page called MyUC.ascx (say in Shared) and want to render it from another page (and pass some view data).&#160; Normally, you would write something like this:</p>  <pre class="brush: csharp;">&lt;% Html.RenderPartial(&quot;MyUC&quot;, data); %&gt;</pre>

<p>Here, “MyUC” is a magic string, and surely it has to go!&#160; T4MVC has always provided a way to do this:</p>

<pre class="brush: csharp;">&lt;% Html.RenderPartial(MVC.Shared.Views.MyUC, data); %&gt;</pre>

<p>Basically, it uses the T4MVC generated view token to avoid using a literal string.&#160; Functional, but ugly!&#160; But now, with this new feature you can simply write:</p>

<pre class="brush: csharp;">&lt;% Html.RenderMyUC(data); %&gt;</pre>

<p>Here, T4MVC generated an extension method specifically to render the partial page, making the code not only free of magic strings, but also more concise and readable.</p>

<p><strong>To disable this functionality</strong>: you can turn this off by setting ExplicitHtmlHelpersForPartials to false in T4MVC.settings.t4</p>

<p>&#160;</p>

<h2>T4MVC talk at MvcConf this Thursday (7/22)</h2>

<p><strong><em></em></strong></p>

<p><strong><em>Update (7/30/2010)</em></strong>: I ended up doing a dual talk on the Razor view engine and T4MVC.&#160; It was a last minute change since we didn’t have a speaker for the Razor talk.&#160; It was a bit of a scramble to get that in, but the talk went well, and is available for all to watch <a href="https://www.viddler.com/explore/mvcconf/videos/20/">here</a>.</p>

<p>&#160;</p>

<p>The other thing I wanted to discuss is the T4MVC talk that I’ll be giving at the <a href="https://mvcconf.com/">MvcConf</a> virtual conference.&#160; The talk will be this Thursday at 12pm Pacific (2pm Central).&#160; Check out the full schedule <a href="https://mvcconf.com/schedule">here</a>.&#160; Here is the talk abstract:</p>

<blockquote>
  <p><b>Name</b>: T4MVC – the magic string killer</p>

  <p><b>Abstract</b>: Magic strings occur frequently in MVC when referring to Controllers, Actions and Views, and lead to code that can be hard to validate and maintain. In this session, I will show you how to use T4MVC (part of MvcContrib) to almost completely obliterate those magic strings.&#160; To make this a bit different from my previous sessions on this topic, I’ll do the demos by starting with a new MVC app from scratch, instead of starting from a complete sample like NerdDinner.&#160; I’ll be running MVC2 on VS 2010, and will include discussion of new MVC features like Areas.&#160; I’ll also present a VS Add-In that can be used to automatically run T4MVC.&#160; Finally, I will discuss how T4MVC can be used with the upcoming Razor view engine.</p>
</blockquote>

<p>Hopefully I’ll see you all there, at least virtually :)</p>

<p><strong>Note:</strong> even though the MvcConf site says that the conference is Sold Out, <a href="https://twitter.com/ehexter">Eric</a> is trying to find a way to stream it more globally (e.g. via ustream).&#160; Check the MvcConf site for updates on this.</p>]]></content:encoded>
    </item>
    <item>
      <title>Check out Chirpy, a very cool Add-In to run T4MVC and do many other cool things</title>
      <link>https://docs.microsoft.com/archive/blogs/davidebb/check-out-chirpy-a-very-cool-add-in-to-run-t4mvc-and-do-many-other-cool-things</link>
      <pubDate>Sat, 17 Jul 2010 21:30:05 GMT</pubDate>
      <dc:creator><![CDATA[David Ebbo]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/davidebb/2010/07/17/check-out-chirpy-a-very-cool-add-in-to-run-t4mvc-and-do-many-other-cool-things/</guid>
      <description><![CDATA[Just a quick post to point folks to a very cool CodePlex Add-In that you may not know about.&#160;...]]></description>
      <content:encoded><![CDATA[<p>Just a quick post to point folks to a very cool CodePlex Add-In that you may not know about.&#160; It’s called Chirpy and can be downloaded from <a href="https://chirpy.codeplex.com/">https://chirpy.codeplex.com/</a>.&#160; The reason I discovered it is that it includes functionality to automatically run T4MVC.&#160; In fact, it is basically the new version of the <a href="https://blog.waynebrantley.com/2010/03/t4mvc-add-in-to-auto-run-template.html">Add-In by Wayne Brantley</a> that I <a href="https://blogs.msdn.com/b/davidebb/archive/2010/03/18/an-even-better-way-to-run-t4mvc-a-vs-addin.aspx">blogged about</a> a few months back.&#160; Wayne has been working on this with <a href="https://twitter.com/weirdmvc">Evan Nagle</a>, who is the main owner.</p>  <p>But note that Chirpy does a lot more than just run T4MVC automatically!&#160; Check out <a href="https://www.weirdlover.com/2010/07/18/chirpy-attains-godlike-abilities-in-version-1-0-0-4/">Evan’s post</a> for a complete tutorial.&#160; To give a really quick intro, Chirpy makes it really easy to automatically:</p>  <ul>   <li>Minify your JavaScript files, using a selction of popular engines like YUI and Closure</li>    <li>Minify your CSS files</li>    <li>Process DotLess files, which make CSS files a lot DRYer.&#160; And then of course minify the resulting CSS per previous point</li>    <li>Mash multiple files together</li>    <li>Validate Javascript and DotLess files</li>    <li>And last but not least (from my selfish point of view!) automatically run T4MVC when you save your files</li> </ul>  <p>But I’m really just paraphrasing Evan’s post, so just check out the details there.&#160; I just played around with most of the functionality, and it all seems to work flawlessly.</p>  <p>It works for both VS 2008 and VS 2010.&#160; Give it a try and see how you like it!</p>]]></content:encoded>
    </item>
    <item>
      <title>How WebMatrix, Razor, ASP.NET Web Pages and MVC fit together</title>
      <link>https://docs.microsoft.com/archive/blogs/davidebb/how-webmatrix-razor-asp-net-web-pages-and-mvc-fit-together</link>
      <pubDate>Wed, 07 Jul 2010 00:29:00 GMT</pubDate>
      <dc:creator><![CDATA[David Ebbo]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/davidebb/2010/07/07/how-webmatrix-razor-asp-net-web-pages-and-mvc-fit-together/</guid>
      <description><![CDATA[Today, we announced the public availability of the Microsoft WebMatrix Beta.&nbsp; This is an...]]></description>
      <content:encoded><![CDATA[<p>Today, we announced the public availability of the <a href="https://www.microsoft.com/web/webmatrix/">Microsoft WebMatrix Beta</a>.&nbsp; This is an exciting time, as we&rsquo;ve been working on this project for quite a while, and have been eager to get it out there!&nbsp; Our VP Scott Guthrie has been blogging about a number of its components in the last week or so, and you should definitely read through his posts to get a lot of information about it (start <a href="https://weblogs.asp.net/scottgu/archive/2010/07/06/introducing-webmatrix.aspx">here</a>).</p>
<p>In this post, I&rsquo;d like to discuss how various pieces fit together, as I&rsquo;ve seen some amount of confusion in the early user comments that I have read.&nbsp; Note that I&rsquo;m not going to describe the pieces in much details (again, see ScottGu&rsquo;s blog for this).&nbsp; Instead, my focus is on clarifying the relationship between some of the pieces.</p>
<p>&nbsp;</p>
<h2>WebMatrix: a stack and a tool</h2>
<p>&nbsp;</p>
<p>Let&rsquo;s start with WebMatrix.&nbsp; The term is actually used is two ways:</p>
<ol>
<li>The WebMatrix <strong>stack </strong>contains a number of things that you get when you <a href="https://www.microsoft.com/web/webmatrix/download/">install it</a> via WebPI:       
<ul>
<li>The new <strong>ASP.NET Web Pages</strong> framework </li>
<li>The <strong>Razor</strong> templating engine </li>
<li>The WebMatrix tool (see #2)</li>
<li>IIS Express</li>
<li>SQL CE 4</li>
</ul>
</li>
<li>The WebMatrix <strong>tool</strong>, which lets you perform various tasks:       
<ul>
<li>Create web apps that use the <strong>Web Pages</strong> framework and the Razor templating engine </li>
<li>Install existing sites from the Web Gallery.&nbsp; Note that those sites don&rsquo;t have to use the Web Pages framework, and in fact most don&rsquo;t (e.g. ScrewTurn wiki, Subtext) </li>
<li>Manage IIS express </li>
<li>Manage SQL CE 4 databases </li>
</ul>
</li>
</ol>
<p><strong>Key point</strong>: the WebMatrix tool is not by any mean the only way to create Web Pages apps.&nbsp; In fact, the Web Pages framework was designed to be very notepad friendly.&nbsp; On the other end of the tooling spectrum, it will later be fully supported by Visual Studio.</p>
<p>&nbsp;</p>
<h2>Razor: a templating engine</h2>
<p>&nbsp;</p>
<p>At its root, Razor is just a templating engine, which is best compared to something like T4.&nbsp; It is also comparable to the aspx and Spark engines.&nbsp; The best way to describe it in its most general sense is:</p>
<ul>
<li>It takes as input:      
<ul>
<li>a template file (with a .cshtml or .vbhtml extension) </li>
<li>some input data: in web scenario, this includes things like an HTTP request, but this is not a requirement </li>
</ul>
</li>
<li>It produces some output string: in web scenario, this is typically a piece of HTML that then gets sent as an HTTP response, but it could be anything. </li>
</ul>
<p>So as an example, you could envision a very simple command line tool that would read an input file and some parameters, and write out the result of running the template on that input.&nbsp; Note that everything I wrote here applies both to Razor and to something like T4.</p>
<p><strong>Key point</strong>: Razor in itself is not tied to MVC nor to the Web Pages framework, and is not even really tied to web applications.</p>
<p>Note: check out <a href="https://blog.andrewnurse.net/">Andrew Nurse&rsquo;s blog</a> for lots of technical details about Razor.</p>
<p>&nbsp;</p>
<h2>ASP.NET Web Pages: a simple framework to write ASP.NET web apps</h2>
<p>&nbsp;</p>
<p>WebMatrix introduces ASP.NET Web Pages, which gives users a simple and powerful new way of writing ASP.NET apps.&nbsp; It is different from WebForms as it doesn&rsquo;t use server controls.&nbsp; It is also different from MVC as it doesn&rsquo;t follow the MVC pattern.&nbsp; Instead, it follows a much simpler &lsquo;inline page&rsquo; model, where a page is basically an HTML page with some code added where needed.&nbsp; In that sense, it is reminiscent of Classic ASP, but it is also very different in the sense that it has the full power of the .NET framework available behind it.&nbsp; It also supports concepts like layout pages which make it much more flexible than the Classic ASP.</p>
<p>Where the discussion gets interesting is that the Web Pages framework <em>uses</em> Razor as its default templating engine.&nbsp; However, it is not <em>tied</em> to Razor.&nbsp; Potentially, you could use the aspx or Spark templating engines with the Web Pages framework.&nbsp; At this point, we have mostly focused on using Razor with it, but it&rsquo;s entirely conceivable that other templating engines would be supported later.</p>
<p><strong>Key point</strong>: ASP.NET Web Pages uses Razor by default, but is not technically tied to it.</p>
<p>&nbsp;</p>
<h2>ASP.NET MVC</h2>
<p>&nbsp;</p>
<p>ASP.NET MVC is not part of the WebMatrix release, as it is a completely different framework with different goals (and this post is not about the pros and cons of the two, so I won&rsquo;t go into that here!).&nbsp; However, it ties into the story because the Razor templating engine will (soon) be made available as an MVC view engine.&nbsp; As it should now be clear, this does not imply that you would be using ASP.NET Web Pages if you choose to use Razor as your MVC view engine.&nbsp; All it means is that you&rsquo;d be using the Razor syntax for your views instead of aspx (or Spark, &hellip;).&nbsp; This has no bearing on how you write your controllers or other parts of your app.</p>
<p><strong>Key point</strong>: Razor syntax will soon be available as an MVC view engine alternative.</p>
<p>&nbsp;</p>
<h2>Conclusion</h2>
<p>&nbsp;</p>
<p>Hopefully, I have been able to clarify how some of the pieces that come with WebMatrix fit together.&nbsp; Please leave a comment if you have any questions and I&rsquo;ll try to clarify further!</p>]]></content:encoded>
    </item>
  </channel>
</rss>