ASP.Net WebAPI

575 views
Skip to first unread message

Matt Johnson

unread,
Jun 5, 2012, 11:52:16 AM6/5/12
to ravendb
Just a word of warning to anyone that may be using RavenDB with the
new ASP.Net WebAPI - or am I the only one? :)

WebAPI, along with the rest of MVC 4, just went from beta to RC
status. In the process, they took on JSON.Net as a dependency, as it
is now the default JSON serializer (replacing Microsoft's own
JavaScriptSerializer).

This is a good thing, of course, but their dependency is on JSON.Net
>= 4.5.1, and as we all know - that doesn't work with the current
RavenDB which requires 4.0.8. Assembly redirection doesn't solve the
problem unfortunately, as there are breaking changes between them. My
understanding is that the JSON.Net versioning issue is resolved in
RavenDB 1.2 by internalizing the JSON.Net library.

So basically, if you are using both WebAPI and RavenDB, you'll need to
stick with the beta of WebAPI until RavenDB 1.2 is released. Don't go
to the RC, even with the new RavenDB build 960.

Kijana Woodard

unread,
Jun 5, 2012, 12:04:52 PM6/5/12
to rav...@googlegroups.com
Thanks for the info.

I had noticed this issue already because of Nuget "nagging" me to upgrade JSON.net to 4.5.1. I just ignore it because of the conflict. 

"DLL Hell" keeps finding ways to resurrect itself. :-)

codin...@googlemail.com

unread,
Jun 5, 2012, 12:29:41 PM6/5/12
to rav...@googlegroups.com
I thought internalizing this lib was done to preempt this issue?

Sent from my iPhone

Kijana Woodard

unread,
Jun 5, 2012, 12:45:40 PM6/5/12
to rav...@googlegroups.com
I think it's internalized in the unstable build atm.


On Tuesday, June 5, 2012 11:29:41 AM UTC-5, (unknown) wrote:
I thought internalizing this lib was done to preempt this issue?

Sent from my iPhone

Matt Johnson

unread,
Jun 5, 2012, 12:52:52 PM6/5/12
to ravendb
Yeah, it's just a matter of timing. When Raven 1.2 is released, it
won't be an issue. If you're on the unstable 1.2 now, it shouldn't be
a problem.

Oren, can you give us a quick update on 1.2 please? Is the current
unstable build good enough for day-to-day development?

Thanks,
Matt

On Jun 5, 9:45 am, Kijana Woodard <kijana.wood...@gmail.com> wrote:
> I think it's internalized in the unstable build atm.
>
>
>
>
>
>
>
> On Tuesday, June 5, 2012 11:29:41 AM UTC-5, (unknown) wrote:
>
> > I thought internalizing this lib was done to preempt this issue?
>
> > Sent from my iPhone
>
> > On 5 Jun 2012, at 17:04, Kijana Woodard <kijana.wood...@gmail.com<kijana.wood...@gmail.com>>

Alexander Zeitler

unread,
Jun 5, 2012, 1:08:50 PM6/5/12
to rav...@googlegroups.com
I switched to 1.2 unstable because of that - no issues until now.

Alex
________________________________________
From: rav...@googlegroups.com [rav...@googlegroups.com] on behalf of Matt Johnson [mj1...@hotmail.com]
Sent: Tuesday, June 05, 2012 5:52 PM
To: ravendb
Subject: [RavenDB] ASP.Net WebAPI

Chanan Braunstein

unread,
Jun 6, 2012, 7:39:49 AM6/6/12
to rav...@googlegroups.com
Hi Alex,

Using RavenDB 1.2 & WebAPI, what are you doing to initialize (& SaveChanges) your DocumentSession? The code that Oren had on the blog doesn't seem to work with RavenDB 1.2 and WebAPI RC.

Oren Eini (Ayende Rahien)

unread,
Jun 7, 2012, 6:40:09 PM6/7/12
to rav...@googlegroups.com
It is good enough for development, yes. But please don't go with that to production yet.
We have done some... interesting changes and we would like to have the chance to test them in a more structured way.

Oren Eini (Ayende Rahien)

unread,
Jun 7, 2012, 6:40:22 PM6/7/12
to rav...@googlegroups.com
What issue do you have?

Chanan Braunstein

unread,
Jun 8, 2012, 9:20:49 AM6/8/12
to rav...@googlegroups.com
Never mind, what it ever it was, when I put the code back it went back to working... Gotta love code that fixes itself...

Fitzchak Yitzchaki

unread,
Jun 14, 2012, 7:12:21 AM6/14/12
to rav...@googlegroups.com
Use the following namesapce: Raven.Imports.Newtonsoft.Json, in order to use the JsonObject that RavenDB uses.

On Thu, Jun 14, 2012 at 2:08 PM, George Goodchild <georgeg...@gmail.com> wrote:
Hi, hopefully a simple question for someone to answer.

I have changed to use an unstable build of Raven because JSON.Net dependency issue described above, however I also need to use the [JsonObject(IsReference = true)] attribute on one of my objects to allow Raven to serialize it without getting stuck in a self-referencing loop.  As I'm using ASP.Net WebAPI in my solution this attribute comes from the 4.5.1 assembly of JSON.Net and Raven ignores it, does anyone have any suggestions as to how to resolve this issue?

Thanks

George

George Goodchild

unread,
Jun 14, 2012, 8:58:54 AM6/14/12
to rav...@googlegroups.com
Perfect thanks.


On Thursday, June 14, 2012 12:12:21 PM UTC+1, Fitzchak Yitzchaki wrote:
Use the following namesapce: Raven.Imports.Newtonsoft.Json, in order to use the JsonObject that RavenDB uses.

Matt Johnson

unread,
Jun 14, 2012, 11:10:00 AM6/14/12
to ravendb
Just an update for those that are interested. I've switched over to
WebAPI RC and RavenDB 1.2 without any major issues. The only breaking
change I've hit so far is that Session.Advanced.DatabaseCommands moved
to Session.Advanced.DocumentStore.DatabaseCommands. No big deal.

We're still in development of course. We'll wait for the stable
release of 1.2 before hitting production.

-Matt

Alexander Zeitler

unread,
Jun 14, 2012, 11:22:29 AM6/14/12
to rav...@googlegroups.com
Same here.

Alex
________________________________________
From: rav...@googlegroups.com [rav...@googlegroups.com] on behalf of Matt Johnson [mj1...@hotmail.com]

Sent: Thursday, June 14, 2012 5:10 PM
To: ravendb
Subject: [RavenDB] Re: ASP.Net WebAPI

Justin A

unread,
Jun 14, 2012, 9:09:43 PM6/14/12
to rav...@googlegroups.com
How are you guys finding using the ASP.NET WebAPI + RavenDb ?


Chanan Braunstein

unread,
Jun 15, 2012, 10:00:39 AM6/15/12
to rav...@googlegroups.com
So far I am using it for ReadOnly purposes only. In that capacity, it is not too different from just returning Json from a controller. I like that I have all the Json feeds in one place all following a simple design. Currently, I am not taking advantage of the OData urls, but I plan to add that in as well shortly.

Looking forward, when SPA gets closer to final code, I may use Upshot.js to do the JS data access which I am not doing manually via jquery in the knockout VM code. 

Alexander Zeitler

unread,
Jun 15, 2012, 10:04:12 AM6/15/12
to rav...@googlegroups.com
AFAIK SPA has been removed in RC and will be out of band release through NuGet.

Web API + RavenDb itself: using them at 3 projects together in development currently and just love them both.

Alex

From: rav...@googlegroups.com [rav...@googlegroups.com] on behalf of Chanan Braunstein [cha...@gmail.com]
Sent: Friday, June 15, 2012 4:00 PM
To: rav...@googlegroups.com
Subject: Re: [RavenDB] Re: ASP.Net WebAPI

Chris Marisic

unread,
Jun 15, 2012, 10:12:18 AM6/15/12
to rav...@googlegroups.com
I'm so glad to see Microsoft releasing software via nuget. There release cycles were just way too long, I hope they start moving towards something much more like continuous delivery.

Matt Johnson

unread,
Jun 15, 2012, 11:13:56 AM6/15/12
to ravendb
I'm also enjoying it very much. I was able to expose IQueryable from
an API action, and return session.Query<MyEntity>(). I can't seem to
find a definitive list of the subset of OData supported by WebAPI, but
it appears to be $top $skip $filter and $orderby. This would seem to
align well with RavenDB's dynamic indexes.

Of course, I can still expose other controllers where I create my own
queries, either dynamically or with static indexes. It all appears to
work perfectly.

As far as writing goes, I'm not doing any writes directly from my
WebAPI controllers. Instead, I'm passing them as commands into to
NServiceBus and writing to raven in the message handlers. Basically,
a CQRS approach. That said, I would think that it would be perfectly
fine to write to raven directly from WebAPI if you're doing standard
CRUD, or using DbDataController / SPA.

About the only thing that I dislike about WebAPI is that MS seems
arrogant in bundling Entity Framework as part of the VS templates.
For us folks using other databases like RavenDB, or those using other
ORMs like NHibernate, it's just noise.

-Matt

On Jun 15, 7:12 am, Chris Marisic <ch...@marisic.com> wrote:
> I'm so glad to see Microsoft releasing software via nuget. There release
> cycles were just way too long, I hope they start moving towards something
> much more like continuous delivery.
>
>
>
>
>
>
>
> On Friday, June 15, 2012 10:04:12 AM UTC-4, Alexander Zeitler wrote:
>
> >  AFAIK SPA has been removed in RC and will be out of band release through
> > NuGet.
>
> >  Web API + RavenDb itself: using them at 3 projects together in
> > development currently and just love them both.
>
> >  Alex
> >  ------------------------------
> > *From:* rav...@googlegroups.com [rav...@googlegroups.com] on behalf of
> > Chanan Braunstein [chan...@gmail.com]
> > *Sent:* Friday, June 15, 2012 4:00 PM
> > *To:* rav...@googlegroups.com
> > *Subject:* Re: [RavenDB] Re: ASP.Net WebAPI

Alexander Zeitler

unread,
Jun 15, 2012, 12:43:40 PM6/15/12
to <ravendb@googlegroups.com>
Yes I dislike EF also but you can easily uninstall it as it is a NuGet package also.

I'm doing writes from the controllers and it works fine at the moment.

I'm avoiding o return entities directly but using dtos (sometimes as hypermedia) instead.

Alex

Stacey

unread,
Jun 15, 2012, 3:19:04 PM6/15/12
to rav...@googlegroups.com
I know this is not the right place for it, but will there be a very explicit list of breaking changes when this 1.2 release comes out? I have been trying to follow it for a few weeks now and am very confused about what is changing.

Oren Eini (Ayende Rahien)

unread,
Jun 15, 2012, 6:28:42 PM6/15/12
to rav...@googlegroups.com
Yes, you can check our issues, it is recorded lice

Stacey Thornton

unread,
Jun 16, 2012, 10:58:36 PM6/16/12
to rav...@googlegroups.com

I am not finding anywhere on the main website that discusses this. Is it nested in the google group?

Oren Eini (Ayende Rahien)

unread,
Jun 17, 2012, 3:02:21 AM6/17/12
to rav...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages