This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>State machine routing prototype</title> | |
</head> | |
<body> | |
<h3>State machine routing concept</h3> | |
<p>Extremely flexible mechanism for defining routes for web applications</p> | |
<ul> | |
<li>Hierarchical | |
</li> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var koProvider = { | |
observable: function () { | |
return ko.observable(); | |
}, | |
computed: function (func) | |
{ | |
return ko.computed(func); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using MongoDB.Bson; | |
using MongoDB.Bson.Serialization; | |
using MongoDB.Bson.Serialization.Attributes; | |
[Serializable] | |
[BsonSerializer(typeof(MongoDocumentClassSerializer))] | |
public class MongoDocument : BsonDocumentBackedClass | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using MongoDB.Bson; | |
using MongoDB.Bson.Serialization; | |
using MongoDB.Bson.Serialization.IdGenerators; | |
using MongoDB.Bson.Serialization.Serializers; | |
public class MongoDocumentClassSerializer : BsonDocumentBackedClassSerializer<MongoDocument>, IBsonIdProvider | |
{ | |
public MongoDocumentClassSerializer() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mongoCollection = database.GetCollection<MongoDocument>("Dynamic"); | |
mongoCollection.Insert( | |
new MongoDocument( | |
new BsonDocument { | |
{ "Name", "A test record" }, | |
{ "Date", new DateTime(2013,01,01) }, | |
{ "Age", 28 }, | |
{ "Complete", false } })); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace LinqToQuerystringPagingSample.Controllers | |
{ | |
using System.Linq; | |
using System.Web.Http; | |
public class ValuesController : ApiController | |
{ | |
// GET api/values | |
public IQueryable<string> Get() | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class WebApiConfig | |
{ | |
public static void Register(HttpConfiguration config) | |
{ | |
var xmlFormatter = config.Formatters.XmlFormatter; | |
config.Formatters.Remove(xmlFormatter); | |
config.Routes.MapHttpRoute( | |
name: "DefaultApi", | |
routeTemplate: "api/{controller}/{id}", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="body"> | |
<section class="featured"> | |
<div class="content-wrapper"> | |
<hgroup class="title"> | |
<h1>Paging with Linq to Querystring</h1> | |
</hgroup> | |
<p> | |
Look how easy it is to page data with OData and Linq to Querystring! | |
</p> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Define the viewmodel | |
var model = {}; | |
model.records = ko.observableArray(); | |
model.count = ko.observable(0); | |
model.currentPage = ko.observable(1); | |
model.pageSize = ko.observable(5); | |
model.pages = ko.computed(function () { | |
var pages = []; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Button click function | |
model.getData = function () { | |
var skip = model.pageSize() * (model.currentPage() - 1); | |
$.get("/api/values?$top=" + model.pageSize() + "&$skip=" + skip + "&$inlinecount=allpages", function (data) { | |
model.count(data.Count); | |
model.records(data.Results); | |
}); | |
}; |