本文整理汇总了C#中Microsoft.Data.Edm.Library.EdmModel.AddEntityContainer方法的典型用法代码示例。如果您正苦于以下问题:C# EdmModel.AddEntityContainer方法的具体用法?C# EdmModel.AddEntityContainer怎么用?C# EdmModel.AddEntityContainer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Data.Edm.Library.EdmModel
的用法示例。
在下文中一共展示了EdmModel.AddEntityContainer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildModel
private static IEdmModel BuildModel(JObject viewObject, out IList<string> fieldsToIgnore)
{
var model = new EdmModel();
fieldsToIgnore = new List<string>();
var name = viewObject.PrimitivePropertyValue<string>("name");
name = name.Replace(' ', '_');
var entityType = new EdmEntityType(false, false, null, "OData4Socrata", name,
Enumerable.Empty<IEdmStructuralProperty>());
var entitySet = new EdmEntitySet(name, entityType);
EdmComplexType phoneComplex = null;
EdmComplexType locationComplex = null;
EdmComplexType urlComplex = null;
foreach (var column in viewObject.ArrayPropertyValue<JObject>("columns"))
{
var fieldName = column.PrimitivePropertyValue<string>("name");
var sodaType = column.PrimitivePropertyValue<string>("dataTypeName");
IEdmTypeReference typeReference;
switch (sodaType)
{
case "meta_data":
fieldsToIgnore.Add(fieldName);
continue;
case "text":
typeReference = EdmLibraryExtensions.GetPrimitiveTypeReference(typeof (string));
break;
case "url":
if (urlComplex == null)
{
urlComplex = new EdmComplexType(false, false, null, entityType.Namespace, "url");
new EdmStructuralProperty(urlComplex, "url", EdmLibraryExtensions.GetPrimitiveTypeReference(typeof (string)),
null, EdmConcurrencyMode.None);
model.AddElement(urlComplex);
}
typeReference = new EdmComplexTypeReference(urlComplex, false);
break;
case "phone":
if (phoneComplex == null)
{
phoneComplex = new EdmComplexType(false, false, null, entityType.Namespace, "phone");
new EdmStructuralProperty(phoneComplex, "phone_number",
EdmLibraryExtensions.GetPrimitiveTypeReference(typeof (string)), null,
EdmConcurrencyMode.None);
new EdmStructuralProperty(phoneComplex, "phone_type",
EdmLibraryExtensions.GetPrimitiveTypeReference(typeof (string)), null,
EdmConcurrencyMode.None);
model.AddElement(phoneComplex);
}
typeReference = new EdmComplexTypeReference(phoneComplex, false);
break;
case "location":
if (locationComplex == null)
{
locationComplex = new EdmComplexType(false, false, null, entityType.Namespace, "location");
new EdmStructuralProperty(locationComplex, "human_address",
EdmLibraryExtensions.GetPrimitiveTypeReference(typeof (string)), null,
EdmConcurrencyMode.None);
new EdmStructuralProperty(locationComplex, "latitude",
EdmLibraryExtensions.GetPrimitiveTypeReference(typeof (string)), null,
EdmConcurrencyMode.None);
new EdmStructuralProperty(locationComplex, "longitude",
EdmLibraryExtensions.GetPrimitiveTypeReference(typeof (string)), null,
EdmConcurrencyMode.None);
new EdmStructuralProperty(locationComplex, "machine_address",
EdmLibraryExtensions.GetPrimitiveTypeReference(typeof (string)), null,
EdmConcurrencyMode.None);
new EdmStructuralProperty(locationComplex, "needs_recoding",
EdmLibraryExtensions.GetPrimitiveTypeReference(typeof (bool)), null,
EdmConcurrencyMode.None);
model.AddElement(locationComplex);
}
typeReference = new EdmComplexTypeReference(locationComplex, false);
break;
default:
throw new Exception();
}
new EdmStructuralProperty(entityType, fieldName, typeReference, null, EdmConcurrencyMode.None);
}
model.AddElement(entityType);
var entityContainer = new EdmEntityContainer();
model.AddEntityContainer(entityContainer);
entityContainer.AddElement(entitySet);
return model;
//.........这里部分代码省略.........