本文整理汇总了C#中ODataConventionModelBuilder.RemoveBaseTypeProperties方法的典型用法代码示例。如果您正苦于以下问题:C# ODataConventionModelBuilder.RemoveBaseTypeProperties方法的具体用法?C# ODataConventionModelBuilder.RemoveBaseTypeProperties怎么用?C# ODataConventionModelBuilder.RemoveBaseTypeProperties使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ODataConventionModelBuilder
的用法示例。
在下文中一共展示了ODataConventionModelBuilder.RemoveBaseTypeProperties方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RemoveBaseTypeProperties_RemovesAllBaseTypePropertiesFromDerivedTypes
public void RemoveBaseTypeProperties_RemovesAllBaseTypePropertiesFromDerivedTypes()
{
var mockType1 = new MockType("Foo").Property<int>("P1");
var mockType2 = new MockType("Bar").BaseType(mockType1).Property<int>("P1").Property<int>("P2");
var mockType3 = new MockType("FooBar").BaseType(mockType2).Property<int>("P1").Property<int>("P2");
var mockAssembly = new MockAssembly(mockType1, mockType2, mockType3);
HttpConfiguration configuration = new HttpConfiguration();
configuration.Services.Replace(typeof(IAssembliesResolver), new TestAssemblyResolver(mockAssembly));
var builder = new ODataConventionModelBuilder(configuration);
var entity1 = builder.AddEntity(mockType1);
entity1.AddProperty(mockType1.GetProperty("P1"));
var entity2 = builder.AddEntity(mockType2).DerivesFrom(entity1);
entity2.AddProperty(mockType2.GetProperty("P2"));
var entity3 = builder.AddEntity(mockType3);
entity3.AddProperty(mockType3.GetProperty("P1"));
entity3.AddProperty(mockType3.GetProperty("P2"));
builder.RemoveBaseTypeProperties(entity3, entity2);
Assert.Empty(entity3.Properties);
}