Ho difficoltà a capire come convertire un valore Enum nel nome corrispondente. Il mio modello è la seguente:Ottenere un Enum da visualizzare sul lato client
public class CatalogRule
{
public int ID { get; set; }
[Display(Name = "Catalog"), Required]
public int CatalogID { get; set; }
[Display(Name = "Item Rule"), Required]
public ItemType ItemRule { get; set; }
public string Items { get; set; }
[Display(Name = "Price Rule"), Required]
public PriceType PriceRule { get; set; }
[Display(Name = "Value"), Column(TypeName = "MONEY")]
public decimal PriceValue { get; set; }
[Display(Name = "Exclusive?")]
public bool Exclude { get; set; }
}
public enum ItemType
{
Catalog,
Category,
Group,
Item
}
public enum PriceType
{
Catalog,
Price_A,
Price_B,
Price_C
}
risultato di un campione da API .net:
[
{
$id: "1",
$type: "XYZ.CMgr.Models.CatalogRule, XYZ.CMgr",
ID: 1,
CatalogID: 501981,
ItemRule: 0,
Items: "198",
PriceRule: 1,
PriceValue: 0.5,
Exclude: false
},
{
$id: "2",
$type: "XYZ.CMgr.Models.CatalogRule, XYZ.CMgr",
ID: 2,
CatalogID: 501981,
ItemRule: 2,
Items: "9899",
PriceRule: 2,
PriceValue: 10.45,
Exclude: false
}
]
Quindi, in questo esempio, ho bisogno di ottenere catalogo per i risultati [0] .ItemRule & Prezzo A per i risultati [0] .PriceRule. Come posso realizzare questo in BreezeJS ??
Durante l'analisi di questo problema, ho scoperto che sebbene i metadati Enum fossero presenti nella chiamata dell'API/Metadata, questa è stata eliminata dal lato client da Breeze. Grazie per l'aggiornamento Jay. –
Breeze v 1.2.1 è stato appena rilasciato e le enumerazioni sono ora interrogabili come stringhe e vengono materializzate in questo modo. –
Per inciso, l'ho aggiornato qualche minuto fa ...;) Questa versione risolve il problema, Grazie ... –