JayData.org

Fullstack OData 4.0 howto–Enums

Author: Robert Bonay January 21st, 2016


This short post presents snippets for publishing and consuming OData services that operate with enums.

Requirements:

.NET server-side data model

public partial class User {

public UserType UserType { get; set; }
… }

Publish custom enum type through OData $metadata service – .NET server-side – Startup.cs

Define custom enum type in JayData data model – JavaScript

$data.Entity.extend(‘JayData.Test.CommonItems.Entities.User’, {

UserType: { type: ‘JayData.Test.CommonItems.Entities.UserType’, nullable: false },
… })

Use custom enum type in JayData – JavaScript

You can read more fullstack OData 4.0 howtos by visiting the following arcticle – Fullstack OData 4.0 howto series with JayData and ASP.NET WebAPI OData