/// <summary>
/// Build the Breeze metadata as a nested Dictionary.
/// The result can be converted to JSON and sent to the Breeze client.
/// </summary>
/// <param name="types">Entity metadata types to include in the metadata</param>
/// <returns></returns>
public Metadata BuildMetadata(IEnumerable <Type> types)
{
InitMap();
_allTypes = types.ToList();
_types = types.Select(t => _describer.Replace(t, types)).Distinct().Where(t => _describer.Include(t)).ToList();
_entityTypes = _types.Where(t => !_describer.IsComplexType(t)).ToList();
var navigations = new List <Dictionary <string, object> >();
foreach (var t in _types)
{
// Add type with data properties
AddType(t);
}
foreach (var t in _types)
{
// Add navigation properties
var cmap = _typeMap[t];
var dataList = (List <Dictionary <string, object> >)cmap["dataProperties"];
var navList = new List <Dictionary <string, object> >();
AddNavigationProperties(t, dataList, navList);
if (navList.Any())
{
cmap.Add("navigationProperties", navList);
navigations.AddRange(navList);
}
}
// resolve associations into association names
ResolveAssociations(navigations);
if (_enumList.Any())
{
_map.Add("enumTypes", _enumList);
}
return(_map);
}