I'm looking into replacing breeze with jaydata on my project, but i'm struggling with enumerations. I'm using the latest updates from nuget together with oData v4.0. I've generated my context with JaySvcUtil.exe without errors. Is the use of enumerations even possible? Can I define the type myself?
Exception: Unable to resolve type:Erp.Entity.Common.State
public class Category : BaseEntity
{
public int? ParentCategoryId { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public string MetaTitle { get; set; }
public string MetaDescription { get; set; }
public int? PictureId { get; set; }
public bool LimitedToStores { get; set; }
public int DisplayOrder { get; set; }
public State State { get; set; } // enum
public bool SyncToShop { get; set; }
public bool Deleted { get; set; }
public DateTimeOffset? DateChanged { get; set; }
public DateTimeOffset? DateCreated { get; set; }
public virtual Category ParentCategory { get; set; }
public virtual Picture Picture { get; set; }
public virtual ICollection<Category> SubCategories { get; set; }
}
public enum State
{
Normal = 0,
Changed = 1,
Night = 2
}
Generate by JaySvcUtil.exe:
$data.Entity.extend('Erp.Entity.Catalog.Category', {
'ParentCategoryId': { 'type':'Edm.Int32' },
'Name': { 'type':'Edm.String' },
'Description': { 'type':'Edm.String' },
'MetaTitle': { 'type':'Edm.String' },
'MetaDescription': { 'type':'Edm.String' },
'PictureId': { 'type':'Edm.Int32' },
'LimitedToStores': { 'type':'Edm.Boolean','nullable':false,'required':true },
'DisplayOrder': { 'type':'Edm.Int32','nullable':false,'required':true },
'State': { 'type':'Erp.Entity.Common.State','nullable':false,'required':true },
'SyncToShop': { 'type':'Edm.Boolean','nullable':false,'required':true },
'Deleted': { 'type':'Edm.Boolean','nullable':false,'required':true },
'DateChanged': { 'type':'Edm.DateTimeOffset' },
'DateCreated': { 'type':'Edm.DateTimeOffset' },
'Id': { 'key':true,'type':'Edm.Int32','nullable':false,'required':true },
'ParentCategory': { 'type':'Erp.Entity.Catalog.Category' },
'Picture': { 'type':'Erp.Entity.Media.Picture' },
'SubCategories': { 'type':'Array','elementType':'Erp.Entity.Catalog.Category' }
});
This is the result when I call my API: http://api.domain.be.local/odata/Categories(3)
{"@odata.context":"http://api.domain.be.local/odata/$metadata#Categories/$entity","ParentCategoryId":2,"Name":"Passion","Description":null,"MetaTitle":null,"MetaDescription":null,"PictureId":null,"LimitedToStores":false,"DisplayOrder":0,"State":"Normal","SyncToShop":true,"Deleted":true,"DateChanged":"2014-03-27T14:39:52.727Z","DateCreated":"2014-03-27T14:39:52.727Z","Id":3}