本文整理汇总了C#中Microsoft.OData.Edm.Library.EdmModel.SetEdmReferences方法的典型用法代码示例。如果您正苦于以下问题:C# EdmModel.SetEdmReferences方法的具体用法?C# EdmModel.SetEdmReferences怎么用?C# EdmModel.SetEdmReferences使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.OData.Edm.Library.EdmModel
的用法示例。
在下文中一共展示了EdmModel.SetEdmReferences方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Register
public static void Register(HttpConfiguration config)
{
var model2 = EdmxReader.Parse(XmlReader.Create("http://localhost:9091/odata/$metadata"));
var model = new EdmModel();
model.AddReferencedModel(model2);
var reference = new EdmReference("http://localhost:9091/odata/$metadata");
reference.AddInclude(new EdmInclude("Model2", "SampleService2.Models"));
model.SetEdmReferences(new List<IEdmReference> { reference });
var container = new EdmEntityContainer("NS1", "Default");
var order = model2.FindDeclaredType("SampleService2.Models.Order") as IEdmEntityType;
model2.SetAnnotationValue<ClrTypeAnnotation>(order, new ClrTypeAnnotation(typeof(Order)));
container.AddEntitySet("Orders", order);
model.AddElement(container);
var product = new EdmEntityType("NS1", "Product");
product.AddKeys(product.AddStructuralProperty("Id", EdmPrimitiveTypeKind.Int32));
product.AddStructuralProperty("Name", EdmPrimitiveTypeKind.String);
model.AddElement(product);
config.MapODataServiceRoute("odata", "odata", model);
}
示例2: MutualReferenceByCodeDemo
private static void MutualReferenceByCodeDemo()
{
Console.WriteLine("MutualReferenceByCodeDemo");
var subModel1 = new EdmModel();
var complex1 = new EdmComplexType("NS1", "Complex1");
subModel1.AddElement(complex1);
var reference1 = new EdmReference("http://model2");
reference1.AddInclude(new EdmInclude("Alias2", "NS2"));
var references1 = new List<IEdmReference> { reference1 };
subModel1.SetEdmReferences(references1);
var subModel2 = new EdmModel();
var complex2 = new EdmComplexType("NS2", "Complex2");
subModel2.AddElement(complex2);
var reference2 = new EdmReference("http://model1");
reference2.AddInclude(new EdmInclude("Alias1", "NS1"));
var references2 = new List<IEdmReference> { reference2 };
subModel2.SetEdmReferences(references2);
complex1.AddStructuralProperty("Prop", new EdmComplexTypeReference(complex2, true));
complex2.AddStructuralProperty("Prop", new EdmComplexTypeReference(complex1, true));
var mainModel = new EdmModel();
var complex3 = new EdmComplexType("NS", "Complex3");
mainModel.AddElement(complex3);
complex3.AddStructuralProperty("Prop1", new EdmComplexTypeReference(complex1, true));
complex3.AddStructuralProperty("Prop2", new EdmComplexTypeReference(complex2, true));
var references3 = new List<IEdmReference> { reference1, reference2 };
mainModel.SetEdmReferences(references3);
ShowModel(mainModel);
ShowModel(subModel1);
ShowModel(subModel2);
}