Sample project with Silverlight and ASP.Net Web API 2

May 2, 2014 at 10:20 PM
Edited May 2, 2014 at 10:21 PM
Hi Tony,

I've been following your tutorials and webcasts religiously - thanks for the great tools. I've based all my projects on your guidelines and was wondering if you can do a demo project on how to use Simple MVVM with Silverlight and Web API 2? I am fairly new to Web APis so any help would be great.

Cheers!
Coordinator
May 3, 2014 at 5:57 AM
The way to go with Web API 2 is to use my other framework: Trackable Entities. This gives you not only Web API, but also code for interacting with a database via Entity Framework. I'll put together a quick sample that shows how to use both Simple MVVM and Trackable Entities together with Web API.

In the meantime, check out Getting Started with Trackable Entities and ASP.NET Web API and watch the 10 minute screencast.

Cheers,
Tony
May 3, 2014 at 8:54 PM
Great, thank you. I'll have a look at your suggestions and I'm looking forward to the sample.
May 3, 2014 at 9:50 PM
Thanks, Tony, I checked out your trackable entities framework and the video however I didn't mention that I'm using mongoDB. Would I be able to mimic the behavior of your framework in a roll-my-own provider to work with a nosql database?
Coordinator
May 4, 2014 at 6:18 AM
Hello Charlie,

Trackable Entities comes with a "Repository and Unit of Work" new project template that decouples everything from Entity Framework. In theory it would be possible to implement a version of the ApplyChanges method in DbContextExtensions.cs that uses MongoDb to apply inserts, updates and deletes by walking up and down an object graph and inspecting the TrackingState property. Then we'd roll that into a NuGet package and reference it from a Service.MongoDb project that would replace the Service.EF project.

However, if change-tracking is overkill for your situation, then you simply need to add a Web API project to your solution, with controllers and actions to perform CRUD operations. Have a look at the Trackable Entities WebApi sample app, where you'll find sample async controllers, as well as a ConsoleClient app that uses HttpClient. For Simple MVVM you'd mainly need to have your client-side entities extend ModelBase, so that they implement INotifyPropertyChanged.

Hope this helps!

Cheers,
Tony
May 4, 2014 at 6:08 PM
Great, thank you for the quick and detailed response. That is exactly what I was looking for!

I'll start without the change-tracking for now. The first suggestion is a bit involved for me at the moment but I can see how it's doable. By the time I'm ready to give it a go you might have a sample project already.

Cheers again for the help.