RavenDB Ids and ASP.NET MVC3 Routes

后端 未结 3 912
误落风尘
误落风尘 2021-02-13 05:15

Just building a quick, simple site with MVC 3 RC2 and RavenDB to test some things out.

I\'ve been able to make a bunch of projects, but I\'m curious as to how Html.Acti

3条回答
  •  醉话见心
    2021-02-13 05:50

    I just downloaded the latest version of RavenDB and tried this out.

    public class Entity {
        public int Id { get;set; }
        public string Text { get;set; }
    }
    

    When I saved it to RavenDB, the id in Raven was "entities/1", but the mapping in RavenDB client was able to successfully interpret the Id from what was in the database to the integer that I wanted.

    var entity = session.Load(1);
    Assert.IsTrue(entity.Id == 1);
    

    You do not need a extension method, and this way you would not need to alter any routes as mentioned above, because you will be dealing with good ol' integers. The string Ids were almost a deal breaker, but amazingly this works so RavenDB is back in the hunt.

    • Note: I figured this out from watching a Rob Ashton talk and realizing that all his document classes had integers as Ids.

提交回复
热议问题