Skip to content

Instantly share code, notes, and snippets.

using System;
using System.ComponentModel.DataAnnotations;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Web.Http;
using System.Web.Http.Controllers;
using System.Web.Http.OData;
using System.Web.Http.OData.Builder;
class Program
{
static void Main(string[] args)
{
ODataConventionModelBuilder builder = new ODataConventionModelBuilder();
builder.EntitySet<Customer>("Customers");
HttpConfiguration config = new HttpConfiguration();
config.Routes.MapODataRoute("odata", "", builder.GetEdmModel());
using System;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using System.Web.Http.Controllers;
using System.Web.Http.Filters;
using Xunit;
using Xunit.Extensions;
namespace TestRoutes
@raghuramn
raghuramn / RouteTesting.cs
Created August 23, 2013 17:48
route testing
using System;
using System.Net;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using System.Web.Http;
using System.Web.Http.Controllers;
using Xunit;
using Xunit.Extensions;
@raghuramn
raghuramn / CustomQueryParameterBinding.cs
Last active December 21, 2015 03:29
Sample showing parameter binding for custom ODataQueryOptions.
using System;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using System.Web.Http;
using System.Web.Http.Controllers;
using System.Web.Http.Metadata;
using System.Web.Http.OData;
using System.Web.Http.OData.Builder;
using System.Web.Http.OData.Query;
@raghuramn
raghuramn / NamedStreams.cs
Created August 15, 2013 00:34
The sample shows how to support named streams with web API OData using some of the extensiblity points in the OData formatter.
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using System.Web.Http.OData;
using System.Web.Http.OData.Builder;
using System.Web.Http.OData.Formatter;
using System.Web.Http.OData.Formatter.Deserialization;
using Microsoft.Data.Edm;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Web.Http;
using System.Web.Http.Controllers;
using System.Web.Http.OData;
public static IEdmModel GetEdmModel(this DbContext context)
{
using (MemoryStream stream = new MemoryStream())
{
using (XmlWriter writer = XmlWriter.Create(stream))
{
EdmxWriter.WriteEdmx(context, writer);
writer.Close();
stream.Seek(0, SeekOrigin.Begin);
using (XmlReader reader = XmlReader.Create(stream))