thoughts on coding

August 11, 2010

String FormatWith Extension

Filed under: Uncategorized — Frantisek @ 12:45 pm

There are plenty of cases when it’s necessary to display any data with the texts. Yes, you can use

string.Format(“My age is {0} year(s)”, age);

but I prefer more fluent interface so I wrote the following extension:

    1 public static string FormatWith(this string text, params object[] args)

    2 {

    3     if (text.IsNullOrEmpty())

    4     {

    5         return string.Empty;

    6     }


    8     return string.Format(text, args);

    9 }

and its usage is

“My age is {0} year(s)”.FormatWith(age)

Isn’t it more fluent and better to read?

The original article was published at


June 24, 2010

Scrum in Practice – stand-up meetings

Filed under: Uncategorized — Tags: , — Frantisek @ 8:02 am

We practice some sort of agile development in our company. It’s based on SCRUM but it’s not pure SCRUM – it’s SCRUM except measuring the velocity.

I pushed the people to use this form os SCRUM on the projects where I’m and I see there is very important to have the stand-up meetings. I write a blog entry about this because I read the article why it’s not so necessary to have it.

The key reasons why I think it’s necessry is:

  1. team reports the progress/problems/plans for the day. We add there also what technology was good and where it can be used (knowledge sharing)
  2. it’s gives us a hint about the team-members productivity

I think, we work in the wawes. If there is no tracking/controlling then I do the work at the latest possible date. Stand-up meetings push the team-member to show what he/she did last day. It he/she is lazy then it’s visible very soon and the team can react on it! I say once again: TEAM! It stays in the team and the team gives him a feedback that if the team wants to have the success then all team-members have to work!

I worked on the project where the team member was this kind of the person and after few stand-up meetings he changed his approach.


  1. stand-up meetings plays more psychological role
  2. can show the PROGRESS of the team-members very soon

Home site:

May 26, 2010

NHibernate in action

Filed under: NHibernate, Uncategorized — Tags: — Frantisek @ 7:28 pm

I started to write on

I posted new blog entry about the book “NHibernate in Action”. Link is NHibernate in Action on

March 26, 2010

StoryQ: scenario enhancements

Filed under: BDD, StoryQ, Uncategorized — Frantisek @ 11:04 am

Thankfully to Rob who inspired me from the comments in my previous post with the easy way how to create the scenario description from the test method name, I decided to share my StoryQ enhancements.

Rob wrote about using a StoryTestBase class with the property Scenario which creates the scenario with the text/name created based on the called method. I extended it little bit. My base class is called StorySpecBase and it contains a property

    1         protected virtual Scenario Scenario

    2         {

    3             get

    4             {

    5                 return WithScenario(StoryQHelper.ConvertTestMethodAsScenario());

    6             }

    7         }

and the helper class called StoryQHelper contains few methods which I use also in Run extension method, now.

    1         public static MethodBase GetTestMethod()

    2         {

    3             var trace = new StackTrace();

    4             for (int i = 0; i < trace.FrameCount; i++)

    5             {

    6                 var methodBase = trace.GetFrame(i).GetMethod();

    7                 bool isTestMethod = methodBase.GetCustomAttributes(true).Any(

    8                     attribute =>

    9                         {

   10                             var name = attribute.GetType().Name;

   11                             if (name == "TestAttribute" || name == "TestMethodAttribute") return true;

   12                             return false;

   13                         });


   15                 if (isTestMethod) return methodBase;

   16             }

   17             return null;

   18         }


   20         public static string GetTestMethodName()

   21         {

   22             var method = GetTestMethod();

   23             if (method == null) return null;


   25             return method.Name;

   26         }


   28         public static string Uncamel(string methodName)

   29         {

   30             return Regex.Replace(methodName, "[A-Z_]", x => " " + x.Value.ToLowerInvariant()).Trim();

   31         }


   33         public static string ConvertTestMethodAsScenario()

   34         {

   35             var methodName = GetTestMethodName();

   36             if (methodName == null) return "Nonamed scenario!";


   38             return Uncamel(GetTestMethodName());

   39         }

The method GetTestMethod uses StackFrames and it tries to find the caller with the attribute Test (Nunit) or TestMethod(MSTest) so I dont have specified fixed stack frame index.

All my tests are derived from StoryQSpecBase and I wrote the tests like:

    1         [Test]

    2         public void ShouldBuildNewStructure()

    3         {

    4             WithScenario("Building new structure")

    5                     .Given(TheModelContainsThaStructureDataWithId_, 0)

    6                     .When(BuildingANewStructure)

    7                     .Then(NewStructureIsFullyBuilt)

    8             .Run();

    9         }

The scenario is named the same way as the test method name :o), which is not very nice.

Now I write them as following:

    1         [Test]

    2         public void ShouldBuildNewStructure()

    3         {

    4             Scenario

    5                     .Given(TheModelContainsThaStructureDataWithId_, 0)

    6                     .When(BuildingANewStructure)

    7                     .Then(NewStructureIsFullyBuilt)

    8             .Run();

    9         }

Nicer, isn’t it? I avoided the string …

March 25, 2010

NBehave out, StoryQ in

Filed under: BDD, NBehave, StoryQ, TDD, Uncategorized — Tags: , — Frantisek @ 10:39 am

I use Behavior Driven Development (BDD) style of the development for last few years. Just for the explanation as I see BDD, BDD is Test-Driven development (TDD) with the description of the tests.

I used TDD in past but I found out that I wrote many comments in the code. Then I started to extract the commented code into the methods whose name was exactly that comment. BDD enables to translate the method names into the text and export that text while running the test. You can find very nice example of this here or exactly the steps I described here. Please note fluent style of the naming the methods and basically all the stuff.

By the way, you can read about the core BDD syntax here.

Until now we used NBehave to define the stories but … I think the biggest disadvantage of this library is the string-adidtive style.

    1          WithScenario("text ......")

    2                 .Given("a text describing give ", "arg", arg => {/* some code*/ })

    3                 .When("a text describing when operation", () => {/* some code*/ })

    4                 .Then("a text describing then operation with expectation", "expectation",  arg => {/* some code*/ })

In case of having 2 tests which share the same test step, i.e. …… it’s recommended (in order to follow DRY principle) to extract the code to the method and use this method in the test.


    1             WithScenario("text ......")

    2                    .Given("a text describing give ", "arg", TextDescribingGiven)

    3                    .When("a text describing when operation", () => {/* some code*/ })

    4                    .Then("a text describing then operation with expectation", "expectation", arg => {/* some code*/ });


    6             WithScenario("text 2......")

    7                    .Given("a text describing give ", "arg", TextDescribingGiven)

    8                    .When("a text describing when operation", () => {/* some code*/ })

    9                    .Then("a text describing then operation with expectation", "expectation", arg => {/* some code*/ });



   12         private void TextDescribingGiven(string arg)

   13         {

   14             /* some code*/

   15         }

It was usual that we changed the code in the step, so we changed the method name, too (using refactoring). But we were too lazy to change also the strings which described the step name. This resulted into wrongly named step decriptions => test description is useless. The developers have to follow very strict rules and you know how hard it is. This functionality was used in NBehave v0.3 and v0.4.

NBehave team released new version 0.4.5 which makes all the above mentioned usage obsolete and dictates us to write the stories in the external file in text form! and then map it (via strings!!!) against the  code! It’s strange step for me because many .NET community stuff tries to avoid using string (i.e. Expressions, etc.) This is hardcore step, I would say. I hate strings and it’s to avoid them as much as possible.  That was the reason why I tried to find out some another library which could create the step description from the method name (methods were named fluently) or we will try to write our own.

We used NBehave for 3 years and we tried to integrate them into NUnit tests with using Resharper to run the tests but …


StoryQ is another BDD library you can use to write the BDD tests but it has the following cooooooool features:

  1. step description is created from the method name, i.e. .Given(IHaveTypedMyCreditCardNumberIntoTheCheckoutPage) => translates to => Given I have typed my credit card number into the checkout page
  2. Nice posibility to add ParameterFormatAttributes
  3. Nice/painless integration into pure NUnit/MSTests testing => integrated into Resharper/VS.NET IDE
  4. Sexy exports into the reports (using XML, XSLT) nicely integrated with continous integration i.e. TFS build server
  5. amazing StoryQ Converter GUI which enables you to write the stories and translate them into the code – it creates testing code envelope!

Check all these features on their web. There is qood documentation.

My comments and enhancements to StoryQ
After using StoryQ for some time I found out that it would good (at least fro my point of the view) the following extensions/changes (we did few of them):

  1. we used to write 1 story in 1 class but with several scenarios. Each scenario is the separated test method. Because there are several strings (again used), I would suggest:
    • scenario description should be created based on the method name
    • story name could be created based on the whole class name

    This extentions/change could avoid using strings. The question is how this could be integrated into NUnit without any pain in order to get the textual representation of the tests.

  2. calling the method  .ExecuteWithSimpleReport(MethodBase.GetCurrentMethod()); we changed to .Run(); using the following extentions method:
  3.    11 public static void Run(this Outcome outcome)

       12         {

       13             StackTrace st = new StackTrace();

       14             outcome.ExecuteWithReport(st.GetFrame(1).GetMethod());

       15         }

  4. Empty String-typed arguments are displayed as ” – nothing – so I created EmptyStringParameterFormatAttribute:
  5.     5 public class EmptyStringParameterFormatAttribute : ParameterFormatAttribute     6     {     7         public override string Format(object value)     8         {     9             if (value != null)    10             {    11                 var str = value as string;    12                 if (str == null || str.Length != 0)    13                 {    14                     return value.ToString();    15                 }    16                 return "empty string";    17             }    18             return "{NULL}";    19     20         }    21     }
  6. It’s big shame that StoryQ Converter doesn’t use T4 templates to generate the code because it would be good to extend/change the default code generation which is currently hard-coded.
  7. It would be good if it would be possible to specify in StoryQ Converter also the argument names, i.e.  when building the shared component with $id:1 => could create a code (BuildingTheSharedComponentWithId, 1) and the method signature could be BuildingTheSharedComponentWithId(int id). It’s just a nice to have feature 😮

I must say StoryQ is really coool library with amazing Converter. Btw, it was really nice to read and know how SrotyQ team developed this library – usign Flit (Fluent Interface toolkit in conjuction with Irony and Dot/GraphViz) which is really coool way and it’s worth another blog posts.

That’s all for now …

March 11, 2010

StructureMap v2.6.1 released!

Filed under: .NET, Di Factory, StructureMap, Uncategorized — Frantisek @ 9:30 pm

There is new version of really usefull library used for DI, IoC – called StructureMap – released. You can find more about that new version on the blog from Jeremy Miller, here

Jeremy explains what was changed there and what’s new but … we miss the up-to-date documentation ….

It’s really cool library, we use it quite much on our projects and it’s really a killer against other similar libraries (I’ll write a post about it later).  I was looking forward to check the new version and use it but here are my comments:

1) API was changed quite massively and there were made obsolete many methods and few were removed. I must say, that the comments used on the Obsolete attribute are not usefull in all situations the old version was able to be used (see example bellow).

2) The release is missing an up-to-date documentation describing how to migrate from old version to the latest version. The migration to the new version is not very straightforward, IMHO. The package (binaries), which you can download from here contains only binaries ;o), no documentation, no tests (which can act as a kind of the document as well), etc.


I think the NUnit tests are very good source of the documentation and explanation how to use the explored library and it should be UP-TO-DATE. So for all who wants to migrate to new version of Structure and dont want to wait for the documention or Jeremy’s blogs I propose the following:

download the full package which includes also NUnit tests 😮 from here (scroll down and take the latest commit, it includes more than 11MBs of data) and spend some time with analyzing code and NUnit tests.

My feedback

I really support the libraries with Fluent approach. Structure map has it but I think, some changes, which should be more fluent in the newer version are less fluent now.

Example: AsSingleton() construct replaced with Singleton(), as following:

I think, more fluent version would be:

I think it’s more fluent. I must say it took me a while to find it out, especially when old construct was completely different with AsSingleton() at the end ;o  I know, my suggestion i’s small change, but I would say, it would bring more fluent voice.

Another, but I think, bigger change was related to situation when we want to add the named instances to the container. It’s connected to the class IInstanceExpression<T> and its OfConcreteType<PLUGGEDTYPE>() method like on the following:

The obsolete attribute advice what to use is nice but useless in the situation when we use AddInstances() construct.

In this case we are not able to avoid using OfConcreteType<T>(). There are 2 possible solutions:

The first is to use the For<T1>().Add<T2>.Named(“name”) like on the following picture:


the old way which was used in 2.5.4 version:

and live with the fact that there will be warnings.

I checked the NUnit tests from StructureMap because I wanted to know how to use this construct correctly and I was disappointed that the there is used the OLD version of the solution (the obsolete methods with the warnings) like the following:


It’s a shame that the release 2.6.1 contains API changes but MANY NUnit tests uses old, Obsolete version of the API. So the documentation is not up-to-date nor the tests.

I think, the team shouldn’t change the API without changing the unit tests to use that new API and thus providing us a solution how to migrate from old  version to the new version.

Anyway, StructureMap is really nice library with many very useful features, going hand in the hand with TDD, Mocking, Plugins, etc. and the biggest advantage is the implementation of Convention over Configuration approach which is unique!

I hope Jeremy will have more free time to blog more about the newest version.

January 4, 2010

SSL support in ASP.NET MVC

Filed under: .NET, ASP.NET MVC — Frantisek @ 9:25 am

I have some views which I need to secure with SSL (HTTPS) and rest should be plain HTTP.  Thankfully, MVC 2 supports RequireSSL attribute to ensure the cuser is performing the action with HTTPS protocol. Fine! Cool!

But if the user is on the view secured by HTTPS then all links (ALL!) created by ActionLink extensions methods are secured! So the question is who/how and when to navigate back to the unsecured links/views?

I tought that the routes configuration is the part where to setup the routes and then we should just use route capabilities to create the links, redirects, etc. In other workds, the configuration is on 1 place and only once! and I can generate the links from all other places. If I want to change the links, I should change only route configuration and all should work well. And whole implemnetaiton should follow DRY principle. But it’s not true. I can’t specify that all links should be sent over HTTP except some special routes which should be handled by HTTPS.

I’ve read several sources how to implement it, i.e. and Steve’s  implementation solves DRY principle but it overwrites VirtualPath to the absolute path and then the special context wrapper corrects it back.  I implemented it different way.

So what is my solution?

The idea behind the scene consists of 3 parts:

1) when configuring the routes, I add the data token scheme to the route definition

routes.Add(new Route("Account/Login", new MvcRouteHandler())
            Defaults = new RouteValueDictionary(new { controller = "Account", action = "Login" }),
            DataTokens = new RouteValueDictionary(new { scheme = "https" })

2) I had to implement and use my own ActionLink extentions methods called MyActionLink (hm, super name, isn’t?). MyActionLink methods are almost same as the default ActionLink implementation except the method with full parameter set.

public static MvcHtmlString MyActionLink(this HtmlHelper htmlHelper, string linkText, string actionName)
            return htmlHelper.MyActionLink(linkText, actionName, null, new RouteValueDictionary(), new RouteValueDictionary());
        public static MvcHtmlString MyActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, object routeValues)
            return htmlHelper.MyActionLink(linkText, actionName, null, new RouteValueDictionary(routeValues), new RouteValueDictionary());
        public static MvcHtmlString MyActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, string controllerName)
            return htmlHelper.MyActionLink(linkText, actionName, controllerName, new RouteValueDictionary(), new RouteValueDictionary());
        public static MvcHtmlString MyActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, RouteValueDictionary routeValues)
            return htmlHelper.MyActionLink(linkText, actionName, null, routeValues, new RouteValueDictionary());
        public static MvcHtmlString MyActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, object routeValues, object htmlAttributes)
            return htmlHelper.MyActionLink(linkText, actionName, null, new RouteValueDictionary(routeValues), new RouteValueDictionary(htmlAttributes));
        public static MvcHtmlString MyActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, RouteValueDictionary routeValues, IDictionary<string, object> htmlAttributes)
            return htmlHelper.MyActionLink(linkText, actionName, null, routeValues, htmlAttributes);
        public static MvcHtmlString MyActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, string controllerName, object routeValues, object htmlAttributes)
            return htmlHelper.MyActionLink(linkText, actionName, controllerName, new RouteValueDictionary(routeValues), new RouteValueDictionary(htmlAttributes));
        public static MvcHtmlString MyActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, string controllerName, RouteValueDictionary routeValues, IDictionary<string, object> htmlAttributes)
            if (string.IsNullOrEmpty(linkText))
                throw new ArgumentNullException(linkText);
            var requestContext = htmlHelper.ViewContext.RequestContext;
            var values = MergeRouteValues(actionName, controllerName, requestContext.RouteData.Values, new RouteValueDictionary(), true);
            var vpd = htmlHelper.RouteCollection.GetVirtualPath(requestContext, values);
            return htmlHelper.ActionLink(linkText, actionName, controllerName,
                (string)vpd.DataTokens["scheme"], (string)vpd.DataTokens["hostname"], null, routeValues, htmlAttributes);

Note: The samilar changes can be done with RedirectToAction<T> and RedirectToAction methods in order to take care of “scheme”. But what I do is that I display the view that the secured action was done successfully and then the user is redirected to i.e. the index view of the controller.

3) decorate the appropriate action with RequireSSL attribute.

        public ActionResult LogOn(LoginInput input)

And that’s all!

And you can use it as you would use ActionLink just with name MyActionLink.  So I replaced all ActionLink(s) to MyActionLink and that was all!

In my project I use MvcContrib. So I changed MvcRoute to include scheme “http” by default, all my links are created by MyActionLink extension method and sensitive actions are decorated with RequireSSL.

Do you know other, better implementation? Please, let me know.

December 16, 2009

Reaction to Dino’s comparism WebForms and MVC

Filed under: ASP.NET MVC — Tags: , — Frantisek @ 5:27 pm

I visited TechEd in Berlin this year with my colleagues and we had a discussion which web technology will we use in the big corporate env in near future. We worked with WebForms for several years and we (in Prague) did several projects with ASP.NET MVC. I muys say, I’m big fan of MVC because it’s finally trying to enables the developers to use the basic development principals like SoC, TDD, IoC/DI which has bug impacts on the code quality, application performance and maintenance! Personally, I think, MVC will be used in majority of the web apps developed in near future on .NET platform.

Anyway, my colleague spent some time searching the comparism and sent me a link from Dino Esposito where the author compares WebForms and ASP.NET MVC. I discussed this article with the colleagues who developed the web apps on MVC and we were really dissapointed with Dino’s article. I knew Dino as the author of ASP.NET web forms articles and based on the article he published on MSDN! about MVC I think, he was he paid by M$ to popularize WebForms over MVC with such junior-level facts or I dont know.

The problem is , Dino is quite know person and it takes a time to explain the people why this his article is so junior-level article selling WebForms. I took me really much time to explain people what was hidden in his article I’dlike to share it with you now.

Dino’s facts:

  • Web Forms allows you to learn as you go.

What? What does it mean? What weak fact is it? Did not ASP.NET MVC allow you to do the same? Come’on man, give me a break! To do the things correcntly (with the focus on QA, performance, etc) is hard! I dont want to use drag’n’drop M$ school, I dont want to use datasets or SQL data source with SQL in the aspx!  

  • Viewstate can be controlled or disabled.

Correctly disable complete viewstate/control state is quite hard work.

  • Web Forms was designed to abstract the Web machinery.

Is is advantage? I think, not! When devleoping apps on WEbForms I had to explain several times to the devleopers where the events occures (client or server?), etc. This abstraction hides many facts which web developers should be aware of!

Dino is presenting that you dont need to know HTML, CSS and JS to do the web forms. That’s the shame. I would compare it to the automechanic who doesn’t have knowledge how to fix the cars but he is fixing them. The result is bad quality. We, web developers, have to know HTML, CSS, JS and we need to have full control over them!

It’s funny how Dino’s presenting the comparism of the life cycles of MVC and WebForms. The page lifecycle is really hard to remember! It’s really hard to learn as you go! It would be fair to compare basic but full page lifecycles and you would see the difference. MVC is much simpler => much faster!

Honestly, I see the following main differences between WebForms and MVC:

  • MVC is more easy to understand and learn. After few years of the web forms developemnt I need to have the page lifecycle painted in the front of me to correctly do the things I want to achieve. It’s heavy and complicated! And I dont mention Viewstate/Controlstate nightmare! I think, MVC is much cleaner approach for the developers.
  • MVC was based in its core to follow TDD approach and it’s cool! Using WebForms it’s harder but you can use i.e. WCSF with MVP pattern.
  • MVC is much faster!  In MVC there is no needed overhead with pagelifecycle, etc. It’s very clear approach and it’s much faster!

There are 2 core requirements from our customers: I need to have good SW quality and I want to have fast application. MVC wins!

I think, MVC could miss the UI components. But this is not true because there are plenty of jQuery components which are free to use, you just need to set them the data and UI layout.

I visited Dino’s blog and he is presenting ASP.NET MVC and say that version 4.0 of ASP.NET is the dead-end! Hm, strange. On one side he is writing how web forms are cool and then next day he is presenting about MVC and he wants to write a book about MVC. No, thanks! There are better professionals than you who wrote about MVC (MVC in action, MVC unleashed).

At the end of the day I’d be very happy if people baid by M$ would inform/present topics more correctly and fairly. I take really too much time to explain other colleagues where the real benefits of the presented technologies are!

April 17, 2009

Fluently with NHibernate

Filed under: Uncategorized — Frantisek @ 8:06 pm

I’m big fan of the fluent interface pattern very much and I try to use it where it makes sense. The pattern is nicely explained on Fowler’s bliki.

In the DAL layer I use NHibernate as O/R mapper and I use ICriteria for quite much cases (especialy when formulating the search criteria for the lists – serach criteria depends on what was filled from the user).

So let’s start.

NHibernate tells the following how to create the criteria (copied from the documentation):

            IList cats = Session.CreateCriteria(typeof (Cat))
                .Add(Expression.Like("name", "Iz%"))
                .Add(Expression.Gt("weight", minWeight));

I wanted to make the creation more fluent like the following:

            IList cats = session.CreateCriteria(typeof(Cat))
                .Add( "name", Is.Like("Iz%") )
                .Add("weight", Is.Gt(minWeight));

I think this is more fluent and it’s possible to read it as 1 sentence which makes the sense, isn’t?

What is necessary to do?

NHibernate extensions:

 /// <summary>
    /// NHibernate extensions
    /// </summary>
    public static class NHibernateExtensions
        /// <summary>
        /// Adds the specified criteria.
        /// </summary>
        /// <param name="criteria">The criteria.</param>
        /// <param name="propertyName">Name of the property.</param>
        /// <param name="expression">The expression.</param>
        /// <returns></returns>
        public static ICriteria Add(this ICriteria criteria, string propertyName, Func<string, ICriterion> expression)
            if (expression.Is())
                ICriterion criterion = expression(propertyName);
                if (criterion.Is())
            return criteria;

and the Is class:

public class Is
        /// <summary>
        /// Equals to.
        /// </summary>
        /// <param name="value">The value.</param>
        public static Func<string, ICriterion> EqualTo(object value)
            return (name => new SimpleExpression(name, value, IsConstants.SignEqual, false));
        /// <summary>
        /// Equals to.
        /// </summary>
        /// <param name="value">The value.</param>
        public static Func<string, ICriterion> EqualTo(int? value)
            if (value.Is())
                return (name => new SimpleExpression(name, value, IsConstants.SignEqual, false));
                return null;
        /// <summary>
        /// Likes the specified name.
        /// </summary>
        /// <param name="value">The value.</param>
        /// <returns></returns>
        public static Func<string, ICriterion> Like(string value)
            if (value.IsNullOrEmpty()) return null;
            return (name => new LikeExpression(name, value, MatchMode.Anywhere, null, true));

I was inspired by NBehave or NUnit libraries which are made very fluent.

What do you think about such added fluency with NHibernate?

March 11, 2009

TT template for MVC Grid with ordering and paging

Filed under: .NET, ASP.NET MVC, MVCContrib, TextTemplate — Tags: , , — Frantisek @ 1:35 pm

In my previous posts I wrote about my extensions to MVCContrib grid like paging and ordering.

It’s tedious work to create the pages with the grid and define all the columns by hand. As you know from MVC RC1 it’s possible to use the TT templates to gerenate the views. I found a TT template fofr MVC Grid somewhere on the web and I extended it to generate the views using my extentions for ordering an paging.

Here is a screenshot from the template:


When you copy such template to the folder:

C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\CSharp\Web\MVC\CodeTemplates\AddView

then you will be able to use it in the dialog:


and here is the result:


While generating the view using the entities which are derived from some base class which is not in the same assembly as the entity, you can get the exception “Could not load type …”. You need to copy the base assembly to the location “C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\\” and then it starts to work properly.

Using such template mechanism the developer can create the lists, details, etc. very quickly . The heart of the whole process is TT template. Just briefly, there is quite exhaustive blog here regarding TT templates.

The template can be found here

« Newer PostsOlder Posts »

Blog at