• Raven.DynamicSession for RavenDB posted on 02 Oct 2012

    Just a word of warning before you read this. I currently don't recommend using this project. MAYBE in the future you could use it, but for now I think it's just a cool proof of concept or something handy for rapid prototyping.

    Last week I had a discussion with @PrabirShrestha in JabbR about APIs for MongoDB to achieve something along the lines of:

    db.posts.insert({title: ''first''}, function(err, doc){})
    

    Example from: http://alexeypetrushin.github.com/mongo-lite/docs/index.html

    Or

    _db.Users.Insert(Name: "Steve", Age: 50);
    

    Example from: http://simplefx.org/simpledata/docs/pages/Modify/AddingData.html

    Looking at the syntax and thinking about C#'s DynamicObject I decided to see what I could come up with. I spent the better part of the next 2-3 hours messing around in Visual Studio, chatting and coming back to it, and came up with this gist.

    https://gist.github.com/3798206

    Read more...

  • NancyFX and Areas posted on 29 Sep 2012

    A while back @ayende wrote a blog post about DinnerParty in which he mentioned NancyFX, a lightweight web framework. @jchannon recently wrote about a blog post about NancyFX RavenDB and himself.

    So I've spent the better part of the last few months learning it, and needless to say, it's awesome. So I got asked a question, how would I handle 'Areas' with Nancy, like we would with ASP.NET MVC?

    Well it's pretty simple, all it really consists of is... a module containing a root path.

    Lets begin with the following folder structure defining a 'HomeModule' for both the Root Website, and the Admin section.

    Both these HomeModule classes are identical, with the small exception that the Admin one specifies a Root Path.

    Read more...

  • My volume gets lowered/reduced when swapping applications (solution) posted on 25 Sep 2012

    I have absolutely no idea who made this retarded feature but if I met them, I would like to think I would punch them in the face for all the pain they have caused me, of making me reformat my computer thinking I had somehow stuffed up my installation of the OS.

    Windows 7 and 8 have this feature which allows an application to take priority of the speakers. Meaning if you're in Application A, and you're playing music, and you swap to Application B, then B will reduce the volume of A so that itself can have louder volume.

    This is really annoying when you want to play music, and then you load up a game, and the music is drowned out by game sounds.

    The solution? Disable that shit!

    1) Go into your Playback devices:

    2) Select the device properties:

    Read more...

  • RavenDB... What am I persisting, what am I querying? (part 3) posted on 19 Jul 2012

    Part 1
    Part 2

    In part 3 I want to show you how to query References.

    In the previous post I showed you three basic classes that demonstrate a Relationship between Order and OrderLine, and a Reference to User from Order using the UserId.

    I've setup some really basic test data:

    using (var session = store.OpenSession())
    {
        session.Store(new User
        {
            FirstName = "Phillip",
            Surname = "Haydon",
            Username = "phillip.haydon",
            Password = "somepassword"
        });
        session.Store(new User
        {
            FirstName = "Edward",
            Surname = "Norton",
            Username = "edward.norton",
            Password = "somepassword"
        });
        session.Store(new Order
        {
            UserId = "users/1",
            DateOrdered = DateTime.Now,
            DateUpdated = DateTime.Now,
            Status = "Ordered",
            Lines = new List<OrderLine>
            {
                new OrderLine
                {
                    Discount = 0m,
                    PricePerUnit = 13.95m,
                    Quantity = 5,
                    SkuCode = "SN78"
                },
                new OrderLine
                {
                    Discount = 0m,
                    PricePerUnit = 13.95m,
                    Quantity = 5,
                    SkuCode = "SN78"
                }
            }
        });
        session.SaveChanges();
    }
    

    This creates two collections:

    Read more...

  • RavenDB... What am I persisting, what am I querying? (part 2) posted on 17 Jul 2012

    Part 1
    Part 2 I want to discuss Relationships & References, and the difference between the two.
    Part 3

    Taking from part 1's example, lets add a User to the mix:

    public class Order
    {
        public string Id { get; set; }
        public string UserId { get; set; }
        public string DateOrdered { get; set; }
        public string DateUpdated { get; set; }
        public string Status { get; set; }
        // Other properties...
        public IEnumerable<OrderLine> Lines { get; set; }
    }
    
    public class OrderLine
    {
        public int Quantity { get; set; }
        public decimal Price { get; set; }
        public decimal Discount { get; set; }
        public string SkuCode { get; set; }
        // Other Properties
    }
    
    public class User
    {
        public string Id { get; set; }
        public string Username { get; set; }
        public string Password { get; set; }
        public string FirstName { get; set; }
        public string Surname { get; set; }
        // Other Properties
    }
    

    As you can see I've added 'UserId' to the Order, not a 'User' just the Id part. This is because I don't want direct access to the User. (It is possible to map a User in RavenDB, but I don't believe that is always a good idea. Save it for special occasions.)

    Read more...

  • RavenDB... What am I persisting, what am I querying? (part 1) posted on 11 Jul 2012

    Part 1
    Part 2
    Part 3

    A couple of questions that pop's up a lot in the #RavenDB JabbR chat room by people picking up RavenDB for the first time are; what am I persisting?, and how do I query relationships?.

    When we use relational databases we often de-normalize our data into multiple tables, usually this is done to get rid of duplication of data. We do this by adding 100's of foreign keys to our tables relating things all over the place, we had a CountryId to our Address, a UserId to our Order, an OrderId to our OrderLine.

    There's many reasons why this was done, some of which Oren describes in his Embracing RavenDB post.

    Then when we go to query those relationships we have to join data, when we have an entity with multiple relationships we end up getting into complex queries with cartesian joins, performance starts to degrade, and things just get messy.

    When working with Document Databases we throw all that out the window and we deal with Root Aggregates. These are objects that are responsible for their child objects, you don't load the child objects individually, they are loaded with the root or parent object.

    Read more...

  • Multiple IISExpress Sites profiled with DotTrace posted on 18 Jun 2012

    Yesterday (14th of June) I had a need to run more than one website while running JetBrain's DotTrace, to give a bit of background, Website A needs to redirect to Website B in order to simulate a single sign on.

    Website B can't be accessed without using the SSO, so in order to profile Website B I need to run Website A.

    The problem is when using DotTrace, I have to select the website I wish to profile:

    The problem with that, is that when you run the profiler it only starts up one of the websites. I need it to start both.

    This would be easy to profile if the Standard Version came with Attach To Process feature. But unfortunately that only comes with Professional.

    That way, when I debug using Visual Studio I could pick the process to profile:

    (Information can be found by right clicking the system try and selecting 'show all applications')

    Read more...

  • ASP.NET MVC 4 has, REAL EMPTY PROJECT! posted on 05 Jun 2012

    I installed Visual Studio 2012 over the weekend, and was BLOWN AWAY when I created a brand new MVC 4 project to find:

    See that 'Empty' project... It now creates:

    Look at that, nice and clean. It still forces the whole WebApi thing on you, but atleast they cut out 90% of the rubbish that was in it previously.

    I'm REALLY happy with the changes after I previously ranted earlier this year:

    MVC 4 Project Templates are stupid

    Thank you Microsoft!

    Read more...

  • Using NHibernate with ServiceStack posted on 05 Jun 2012

    A few people have asked me how they can use ServiceStack with other persistence technologies like RavenDB and NHibernate, or if you really must... EntityFramework... Rather than ServiceStack.OrmLite or ServiceStack.Redis like many of the examples in SS show.

    Note: This isn't about best practice on using NHibernate or ServiceStack, my services are named just to quickly get something up and running.

    Note 2: This blog post may not be completely inline with the GitHub repository since I will be updating the repository to include some additional samples in the future.

    I've created a small sample project which can be found here on GitHub, I plan to flesh it out a little bit from the date this is posted, but it's purely there as a sample.

    No Repositories!

    Utilizing other persistence frameworks is really easy with ServiceStack, the thing with ServiceStack Services is that they are doing something concise, it's a single service implementation, so there's really no need to use repositories for them, you gain absolutely no benefit from using repositories other than adding an additional layer of abstraction and complexity to your services.

    Read more...

  • CodeSchool.com is the most awesome way to learn posted on 11 Apr 2012

    On the 1st of April, Glenn Block posted a link that was too good to be true.

    http://www.codeschool.com

    I have a habit of checking out most links that don't look like they link to a porn site or some look at photo of me and signup to see me naked. This particular link interested me because his tweet mentioned Backbone, something I've been wanting to learn for a while and that I'm been hoping Derick Bailey would add to his awesome JavaScript video collection: http://www.watchmecode.net (his JavaScript series is absolutely brilliant and I've learnt SO much from him so go support him so he will make more plz kthxbi)

    Anyway CodeSchool allows you to do level 1 of most courses for free, and if you like what you try you can purchase the rest of the course. Buying the courses 1 by 1 is a little bit expensive at $55 USD, but it's well worth the money.

    You're not getting just a video like you would with sites like Plural Sight, Tekpub, or any of the many other site's popping up lately.

    After each lesson in the course, there's a series of challenges which allow you to utilize your new gained knowledge and put it to the test. The Backbone course challenges you to make a small ToDo list application, starting out really basic and slowly modifying the code to follow best practice, or add new features.

    Read more...