Skip to content

Metadata APIs

Common Usage

//Get the in-memory representation represented by a CSDL document
CsdlDocument csdldoc = demoService.getMetadata();
EntityTypeMap typeMap = csdldoc.getEntityTypes();
EntityType productType = typeMap.get("ODataAPI.Event");

//Refresh metadata by getting it again from back-end URL
//demoService.refreshMetadata();

//Get entity sets available in DemoService
EntitySetMap esm = csdldoc.getEntitySets();
//["ODataDemo.DemoService/Categories","ODataDemo.DemoService/Products","ODataDemo.DemoService/Suppliers"]
//Returns fully qualified names of entity sets <name space>.<container name>/<entity set name>
StringList entitySets = esm.keys();

//Get fully qualified name of entity container
EntityContainerMap ecm = csdldoc.getEntityContainers();
EntityContainer container = ecm.get("ODataDemo.DemoService");

//Get a specific entity set
EntitySet products = csdldoc.getEntitySet("Products");

//Get a specific entity set using qualified name
products = csdldoc.getEntitySet("DemoService.Products");
//OR
products = csdldoc.getEntitySet("ODataDemo.DemoService/Products");

//Get entity set via DemoService which will delegate to the in-memory metadata representation
EntitySet products2 = demoService.getEntitySet("Products");
products2 = demoService.getEntitySet("DemoService.Products");

//check if entity set was added since metadata was originally loaded
boolean isNew = products.isExtension();

EntityType productDetail = csdldoc.getEntityType("ODataDemo.Product");
//get entity types defined in a demoService
EntityTypeMap etm = csdldoc.getEntityTypes();
StringList entityTypes = etm.keys();
//Get the in-memory representation represented by a CSDL document
val csdldoc = demoService.metadata
val typeMap = csdldoc.entityTypes
val productType = typeMap.get("ODataAPI.Event")

//Refresh metadata by getting it again from back-end URL
//demoService.refreshMetadata()

//Get entity sets available in DemoService
val esm = csdldoc.entitySets
//["ODataDemo.DemoService/Categories","ODataDemo.DemoService/Products","ODataDemo.DemoService/Suppliers"]
//Returns fully qualified names of entity sets <name space>.<container name>/<entity set name>
val entitySets = esm.keys()

//Get fully qualified name of entity container
val ecm = csdldoc.entityContainers
val container = ecm.get("ODataDemo.DemoService")

//Get a specific entity set
val products = csdldoc.getEntitySet("Products")

//Get a specific entity set using qualified name
val products = csdldoc.getEntitySet("DemoService.Products")
//OR
val products = csdldoc.getEntitySet("ODataDemo.DemoService/Products")

//Get entity set via DemoService which will delegate to the in-memory metadata representation
val products2 = demoService.getEntitySet("Products")
products2 = demoService.getEntitySet("DemoService.Products")

//check if entity set was added since metadata was originally loaded
val isNew = products.isExtension

val productDetail = csdldoc.getEntityType("ODataDemo.Product")
//get entity types defined in a demoService
val etm = csdldoc.entityTypes
val entityTypes = etm.keys()

Last update: April 14, 2021