Are you using Cassette?

יום שלישי, מרץ 20, 2012

ASP.NET 4.5 Developer Preview introduces a new capability to manage scripts bundling and minification. You can read about it here. However, the current implementation lacks a very important aspect of scripts management which is managing the dependencies. As you know, when referencing a single script file you also need to reference all its dependencies. Wouldn't it be nice if someone automatically injects the right dependencies? Enter Cassette world ... Cassette is an HttpModule which seats inside ASP.NET pipeline and monitors requests for scripts and CSS. Cassette can automatically bundle and minify your code and even more interesting it can parse each...

Exclude A Filter

יום שישי, אוקטובר 28, 2011

In my last ASP.NET MVC MSDN session I was asked a simple question: "How can we disable a filter for a specific action, assuming it is already defined at the class level?" Of course, having this ability can really ease the maintenance of our application. Without this ability we need NOT to define the filter at the class level and then define at each action level. Well, I did not have any simple question. However, I claimed that such an infrastructure can be easily developed using the excellent ASP.NET MVC extensibility support. Is that so? Let's try do it Full sample code...

Source Control with SVN

יום שישי, אפריל 22, 2011

Since 2005 I've been mostly working with Microsoft Team Foundation Server to manage my source code. Before that I had the chance to work with Microsoft Source Safe and even a bit with WinCVS (for self projects) These days I am back again working on a self project and need to share my source code with two other developers. All roads led me to SVN.I was quite surprised how easily an SVN server can be installed and manipulated from Windows Explorer. So I decided to share this info with you. There are several implementations of SVN server you can use. I...

Implementing Composite Pattern with Entity Framework Code First – Part 2

יום חמישי, מרץ 17, 2011

In my previous blog post I described the way you can implement Composite pattern using Entity Framework Code First. The sample uses EFCodeFirst CTP 5 which suffers from a minor bug related to the composite relationship. Microsoft just released EF 4.1 RC which fixes the issue. Now, you can implement your composite pattern in a clean fashion. You can find the fixed composite pattern sample here.  

Implementing Composite Pattern with Entity Framework Code First

יום רביעי, מרץ 2, 2011

The full sample code can be downloaded here Entity Framework allows us to map object relationships into a database. One of the useful relationship is the Composite Pattern. Suppose we have implemented the following class diagram: As you can see this is a classical implementation of the Composite design pattern, where Group holds a collection of polymorphic items through the property Items of type BookItem. We would like to save this model into a database using Entity Framework Code First.According to ECCodeFirst coding convention guidelines we should define the following classes:public abstract class BookItem {     public int ID { get; set; }     public virtual Group Parent { get; set; }     public abstract void Accept(IBookVisitor visitor); } public class Group : BookItem {     public string Name { get; set; }     public virtual ICollection<BookItem> Items { get; set; }     public Group()     {         this.Items = new List<BookItem>();     }     public override void Accept(IBookVisitor visitor) {...} } public class Person : BookItem {     public string FirstName { get; set; }     public string LastName { get; set; }     public virtual ICollection<Address> Addresses { get; set; }     public Person()     {         this.Addresses = new List<Address>();     }     public override void Accept(IBookVisitor visitor) {...} } public class Address {     public int ID { get; set; }     public string Value { get; set; }     public string Description { get; set; }     public virtual Person Parent { get; set; }     public int PersonID { get; set; }     public void Accept(IBookVisitor visitor) {...} } public class BookContext : DbContext {     public DbSet<BookItem> Items { get; set; }     public BookContext()         : base("AddressBook")     { }     protected override void OnModelCreating(ModelBuilder model)     {         model.Entity<BookItem>().ToTable("BookItems");         model.Entity<Person>().ToTable("Persons");         model.Entity<Group>().ToTable("Groups");         model.Entity<Address>().HasRequired(a => a.Parent) ...

MSDN Session – Introducing ASP.NET MVC

יום רביעי, פברואר 23, 2011

Yesterday I delivered a nice (hopefully) MSDN session at Microsoft. During the session I presented the main features/goodies that were released during January month as part of ASP.NET MVC 3 release. The session was 4 hours long and was quite intense. During the first part of the session I built an application from scratch adding at each step a new functionality like editing capabilities, controlling access and routing system manipulation.During the second part I introduced the new features of ASP.NET MVC 3 and related technologies. Specifically I talked about: Razor syntax NuGet IIS Express Entity Framework Code First ASP.NET MVC 3 specific enhancements  Many participants...