本文整理汇总了C#中Microsoft.OData.Edm.Library.EdmEntityType.AddUnidirectionalNavigation方法的典型用法代码示例。如果您正苦于以下问题:C# EdmEntityType.AddUnidirectionalNavigation方法的具体用法?C# EdmEntityType.AddUnidirectionalNavigation怎么用?C# EdmEntityType.AddUnidirectionalNavigation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.OData.Edm.Library.EdmEntityType
的用法示例。
在下文中一共展示了EdmEntityType.AddUnidirectionalNavigation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InstanceAnnotationsReaderIntegrationTests
static InstanceAnnotationsReaderIntegrationTests()
{
EdmModel modelTmp = new EdmModel();
EntityType = new EdmEntityType("TestNamespace", "TestEntityType");
modelTmp.AddElement(EntityType);
var keyProperty = new EdmStructuralProperty(EntityType, "ID", EdmCoreModel.Instance.GetInt32(false));
EntityType.AddKeys(new IEdmStructuralProperty[] { keyProperty });
EntityType.AddProperty(keyProperty);
var resourceNavigationProperty = EntityType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo { Name = "ResourceNavigationProperty", Target = EntityType, TargetMultiplicity = EdmMultiplicity.ZeroOrOne });
var resourceSetNavigationProperty = EntityType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo { Name = "ResourceSetNavigationProperty", Target = EntityType, TargetMultiplicity = EdmMultiplicity.Many });
var defaultContainer = new EdmEntityContainer("TestNamespace", "DefaultContainer_sub");
modelTmp.AddElement(defaultContainer);
EntitySet = new EdmEntitySet(defaultContainer, "TestEntitySet", EntityType);
EntitySet.AddNavigationTarget(resourceNavigationProperty, EntitySet);
EntitySet.AddNavigationTarget(resourceSetNavigationProperty, EntitySet);
defaultContainer.AddElement(EntitySet);
Singleton = new EdmSingleton(defaultContainer, "TestSingleton", EntityType);
Singleton.AddNavigationTarget(resourceNavigationProperty, EntitySet);
Singleton.AddNavigationTarget(resourceSetNavigationProperty, EntitySet);
defaultContainer.AddElement(Singleton);
ComplexType = new EdmComplexType("TestNamespace", "TestComplexType");
ComplexType.AddProperty(new EdmStructuralProperty(ComplexType, "StringProperty", EdmCoreModel.Instance.GetString(false)));
modelTmp.AddElement(ComplexType);
Model = TestUtils.WrapReferencedModelsToMainModel("TestNamespace", "DefaultContainer", modelTmp);
}
示例2: ExapndOptionFunctionalTests
static ExapndOptionFunctionalTests()
{
string namespaceA = "NS";
EdmModel edmModel = new EdmModel();
EdmEntityType type1 = new EdmEntityType(namespaceA, "T1");
EdmEntityType type2 = new EdmEntityType(namespaceA, "T2", type1);
EdmEntityType type3 = new EdmEntityType(namespaceA, "T3", type2);
EdmNavigationProperty nav21 = type2.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo()
{
Name = "Nav21",
ContainsTarget = false,
Target = type1,
TargetMultiplicity = EdmMultiplicity.ZeroOrOne,
});
EdmNavigationProperty nav22 = type2.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo()
{
Name = "Nav22",
ContainsTarget = false,
Target = type2,
TargetMultiplicity = EdmMultiplicity.One,
});
EdmNavigationProperty nav23 = type2.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo()
{
Name = "Nav23",
ContainsTarget = false,
Target = type3,
TargetMultiplicity = EdmMultiplicity.Many,
});
edmModel.AddElement(type1);
edmModel.AddElement(type2);
edmModel.AddElement(type3);
EdmEntityContainer container = new EdmEntityContainer(namespaceA, "Con1");
var set1 = container.AddEntitySet(namespaceA, type1);
var set2 = container.AddEntitySet(namespaceA, type2);
var set3 = container.AddEntitySet(namespaceA, type3);
edmModel.AddElement(container);
set2.AddNavigationTarget(nav21, set1);
set2.AddNavigationTarget(nav22, set2);
set2.AddNavigationTarget(nav23, set3);
Model = edmModel;
T2Type = type2;
T3Type = type3;
T2Set = set2;
T3Set = set3;
}
示例3: EdmDeltaModel
public EdmDeltaModel(IEdmModel source, IEdmEntityType entityType, IEnumerable<string> propertyNames)
{
_source = source;
_entityType = new EdmEntityType(entityType.Namespace, entityType.Name);
foreach (var property in entityType.StructuralProperties())
{
if (propertyNames.Contains(property.Name))
_entityType.AddStructuralProperty(property.Name, property.Type, property.DefaultValueString, property.ConcurrencyMode);
}
foreach (var property in entityType.NavigationProperties())
{
if (propertyNames.Contains(property.Name))
{
var navInfo = new EdmNavigationPropertyInfo()
{
ContainsTarget = property.ContainsTarget,
DependentProperties = property.DependentProperties(),
PrincipalProperties = property.PrincipalProperties(),
Name = property.Name,
OnDelete = property.OnDelete,
Target = property.Partner != null
? property.Partner.DeclaringEntityType()
: property.Type.TypeKind() == EdmTypeKind.Collection
? (property.Type.Definition as IEdmCollectionType).ElementType.Definition as IEdmEntityType
: property.Type.TypeKind() == EdmTypeKind.Entity
? property.Type.Definition as IEdmEntityType
: null,
TargetMultiplicity = property.TargetMultiplicity(),
};
_entityType.AddUnidirectionalNavigation(navInfo);
}
}
}
示例4: GetModel
private EdmModel GetModel()
{
EdmModel model = new EdmModel();
EdmEntityType edmEntityType = new EdmEntityType("NS", "Person");
edmEntityType.AddKeys(edmEntityType.AddStructuralProperty("ID", EdmPrimitiveTypeKind.Int32));
edmEntityType.AddStructuralProperty("Color", EdmPrimitiveTypeKind.String);
edmEntityType.AddStructuralProperty("FA", EdmPrimitiveTypeKind.String);
edmEntityType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo { Name = "MyDog", TargetMultiplicity = EdmMultiplicity.ZeroOrOne, Target = edmEntityType });
edmEntityType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo { Name = "MyCat", TargetMultiplicity = EdmMultiplicity.ZeroOrOne, Target = edmEntityType });
model.AddElement(edmEntityType);
EdmEntityContainer container = new EdmEntityContainer("NS", "EntityContainer");
model.AddElement(container);
container.AddEntitySet("People", edmEntityType);
return model;
}
示例5: MultipleSchemasWithDifferentNamespacesEdm
public static IEdmModel MultipleSchemasWithDifferentNamespacesEdm()
{
var namespaces = new string[]
{
"FindMethodsTestModelBuilder.MultipleSchemasWithDifferentNamespaces.first",
"FindMethodsTestModelBuilder.MultipleSchemasWithDifferentNamespaces.second"
};
var model = new EdmModel();
foreach (var namespaceName in namespaces)
{
var entityType1 = new EdmEntityType(namespaceName, "validEntityType1");
entityType1.AddKeys(entityType1.AddStructuralProperty("Id", EdmPrimitiveTypeKind.Int32));
var entityType2 = new EdmEntityType(namespaceName, "VALIDeNTITYtYPE2");
entityType2.AddKeys(entityType2.AddStructuralProperty("Id", EdmPrimitiveTypeKind.Int32));
var entityType3 = new EdmEntityType(namespaceName, "VALIDeNTITYtYPE3");
entityType3.AddKeys(entityType3.AddStructuralProperty("Id", EdmPrimitiveTypeKind.Int32));
entityType1.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo {Name = "Mumble", Target = entityType2, TargetMultiplicity = EdmMultiplicity.Many});
var complexType = new EdmComplexType(namespaceName, "ValidNameComplexType1");
complexType.AddStructuralProperty("aPropertyOne", new EdmComplexTypeReference(complexType, false));
model.AddElements(new IEdmSchemaElement[] { entityType1, entityType2, entityType3, complexType });
var function1 = new EdmFunction(namespaceName, "ValidFunction1", EdmCoreModel.Instance.GetSingle(false));
var function2 = new EdmFunction(namespaceName, "ValidFunction1", EdmCoreModel.Instance.GetSingle(false));
function2.AddParameter("param1", new EdmEntityTypeReference(entityType1, false));
var function3 = new EdmFunction(namespaceName, "ValidFunction1", EdmCoreModel.Instance.GetSingle(false));
function3.AddParameter("param1", EdmCoreModel.Instance.GetSingle(false));
model.AddElements(new IEdmSchemaElement[] {function1, function2, function3});
}
return model;
}
示例6: GetModel
public void GetModel(EdmModel model, EdmEntityContainer container)
{
EdmEntityType student = new EdmEntityType("ns", "Student");
student.AddStructuralProperty("Name", EdmPrimitiveTypeKind.String);
EdmStructuralProperty key = student.AddStructuralProperty("ID", EdmPrimitiveTypeKind.Int32);
student.AddKeys(key);
model.AddElement(student);
EdmEntitySet students = container.AddEntitySet("Students", student);
EdmEntityType school = new EdmEntityType("ns", "School");
school.AddKeys(school.AddStructuralProperty("ID", EdmPrimitiveTypeKind.Int32));
school.AddStructuralProperty("CreatedDay", EdmPrimitiveTypeKind.DateTimeOffset);
model.AddElement(school);
EdmEntitySet schools = container.AddEntitySet("Schools", student);
EdmNavigationProperty schoolNavProp = student.AddUnidirectionalNavigation(
new EdmNavigationPropertyInfo
{
Name = "School",
TargetMultiplicity = EdmMultiplicity.One,
Target = school
});
students.AddNavigationTarget(schoolNavProp, schools);
_school = school;
}
示例7: GetEdmModel
public static IEdmModel GetEdmModel()
{
EdmModel model = new EdmModel();
// Create and add product entity type.
EdmEntityType product = new EdmEntityType("NS", "Product");
product.AddKeys(product.AddStructuralProperty("Id", EdmPrimitiveTypeKind.Int32));
product.AddStructuralProperty("Name", EdmPrimitiveTypeKind.String);
product.AddStructuralProperty("Price", EdmPrimitiveTypeKind.Double);
model.AddElement(product);
// Create and add category entity type.
EdmEntityType category = new EdmEntityType("NS", "Category");
category.AddKeys(category.AddStructuralProperty("Id", EdmPrimitiveTypeKind.Int32));
category.AddStructuralProperty("Name", EdmPrimitiveTypeKind.String);
model.AddElement(category);
// Set navigation from product to category.
EdmNavigationPropertyInfo propertyInfo = new EdmNavigationPropertyInfo();
propertyInfo.Name = "Category";
propertyInfo.TargetMultiplicity = EdmMultiplicity.One;
propertyInfo.Target = category;
EdmNavigationProperty productCategory = product.AddUnidirectionalNavigation(propertyInfo);
// Create and add entity container.
EdmEntityContainer container = new EdmEntityContainer("NS", "DefaultContainer");
model.AddElement(container);
// Create and add entity set for product and category.
EdmEntitySet products = container.AddEntitySet("Products", product);
EdmEntitySet categories = container.AddEntitySet("Categories", category);
products.AddNavigationTarget(productCategory, categories);
return model;
}
示例8: ReferentialConstraintDemo
private static void ReferentialConstraintDemo()
{
Console.WriteLine("ReferentialConstraintDemo");
EdmModel model = new EdmModel();
var customer = new EdmEntityType("ns", "Customer");
model.AddElement(customer);
var customerId = customer.AddStructuralProperty("Id", EdmPrimitiveTypeKind.Int32, false);
customer.AddKeys(customerId);
var address = new EdmComplexType("ns", "Address");
model.AddElement(address);
var code = address.AddStructuralProperty("gid", EdmPrimitiveTypeKind.Guid);
customer.AddStructuralProperty("addr", new EdmComplexTypeReference(address, true));
var order = new EdmEntityType("ns", "Order");
model.AddElement(order);
var oId = order.AddStructuralProperty("Id", EdmPrimitiveTypeKind.Int32, false);
order.AddKeys(oId);
var orderCustomerId = order.AddStructuralProperty("CustomerId", EdmPrimitiveTypeKind.Int32, false);
var nav = new EdmNavigationPropertyInfo()
{
Name = "NavCustomer",
Target = customer,
TargetMultiplicity = EdmMultiplicity.One,
DependentProperties = new[] { orderCustomerId },
PrincipalProperties = new[] { customerId }
};
order.AddUnidirectionalNavigation(nav);
ShowModel(model);
}
示例9: CreateModel
public static IEdmModel CreateModel(string ns)
{
EdmModel model = new EdmModel();
var defaultContainer = new EdmEntityContainer(ns, "DefaultContainer");
model.AddElement(defaultContainer);
var addressType = new EdmComplexType(ns, "Address");
addressType.AddProperty(new EdmStructuralProperty(addressType, "Road", EdmCoreModel.Instance.GetString(false)));
addressType.AddProperty(new EdmStructuralProperty(addressType, "City", EdmCoreModel.Instance.GetString(false)));
model.AddElement(addressType);
var personType = new EdmEntityType(ns, "Person");
var personIdProperty = new EdmStructuralProperty(personType, "PersonId", EdmCoreModel.Instance.GetInt32(false));
personType.AddProperty(personIdProperty);
personType.AddKeys(new IEdmStructuralProperty[] { personIdProperty });
personType.AddProperty(new EdmStructuralProperty(personType, "FirstName", EdmCoreModel.Instance.GetString(false)));
personType.AddProperty(new EdmStructuralProperty(personType, "LastName", EdmCoreModel.Instance.GetString(false)));
personType.AddProperty(new EdmStructuralProperty(personType, "Address", new EdmComplexTypeReference(addressType, true)));
personType.AddProperty(new EdmStructuralProperty(personType, "Descriptions", new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetString(false)))));
model.AddElement(personType);
var peopleSet = new EdmEntitySet(defaultContainer, "People", personType);
defaultContainer.AddElement(peopleSet);
var numberComboType = new EdmComplexType(ns, "NumberCombo");
numberComboType.AddProperty(new EdmStructuralProperty(numberComboType, "Small", EdmCoreModel.Instance.GetInt32(false)));
numberComboType.AddProperty(new EdmStructuralProperty(numberComboType, "Middle", EdmCoreModel.Instance.GetInt64(false)));
numberComboType.AddProperty(new EdmStructuralProperty(numberComboType, "Large", EdmCoreModel.Instance.GetDecimal(false)));
model.AddElement(numberComboType);
var productType = new EdmEntityType(ns, "Product");
var productIdProperty = new EdmStructuralProperty(productType, "ProductId", EdmCoreModel.Instance.GetInt32(false));
productType.AddProperty(productIdProperty);
productType.AddKeys(new IEdmStructuralProperty[] { productIdProperty });
productType.AddProperty(new EdmStructuralProperty(productType, "Quantity", EdmCoreModel.Instance.GetInt64(false)));
productType.AddProperty(new EdmStructuralProperty(productType, "LifeTimeInSeconds", EdmCoreModel.Instance.GetDecimal(false)));
productType.AddProperty(new EdmStructuralProperty(productType, "TheCombo", new EdmComplexTypeReference(numberComboType, true)));
productType.AddProperty(new EdmStructuralProperty(productType, "LargeNumbers", new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetDecimal(false)))));
model.AddElement(productType);
var productsSet = new EdmEntitySet(defaultContainer, "Products", productType);
defaultContainer.AddElement(productsSet);
var productsProperty = personType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo
{
Name = "Products",
Target = productType,
TargetMultiplicity = EdmMultiplicity.Many
});
peopleSet.AddNavigationTarget(productsProperty, productsSet);
IEnumerable<EdmError> errors;
model.Validate(out errors);
return model;
}
示例10: CreateServiceEdmModel
public static IEdmModel CreateServiceEdmModel(string ns)
{
EdmModel model = new EdmModel();
var defaultContainer = new EdmEntityContainer(ns, "PerfInMemoryContainer");
model.AddElement(defaultContainer);
var personType = new EdmEntityType(ns, "Person");
var personIdProperty = new EdmStructuralProperty(personType, "PersonID", EdmCoreModel.Instance.GetInt32(false));
personType.AddProperty(personIdProperty);
personType.AddKeys(new IEdmStructuralProperty[] { personIdProperty });
personType.AddProperty(new EdmStructuralProperty(personType, "FirstName", EdmCoreModel.Instance.GetString(false)));
personType.AddProperty(new EdmStructuralProperty(personType, "LastName", EdmCoreModel.Instance.GetString(false)));
personType.AddProperty(new EdmStructuralProperty(personType, "MiddleName", EdmCoreModel.Instance.GetString(true)));
personType.AddProperty(new EdmStructuralProperty(personType, "Age", EdmCoreModel.Instance.GetInt32(false)));
model.AddElement(personType);
var simplePersonSet = new EdmEntitySet(defaultContainer, "SimplePeopleSet", personType);
defaultContainer.AddElement(simplePersonSet);
var largetPersonSet = new EdmEntitySet(defaultContainer, "LargePeopleSet", personType);
defaultContainer.AddElement(largetPersonSet);
var addressType = new EdmComplexType(ns, "Address");
addressType.AddProperty(new EdmStructuralProperty(addressType, "Street", EdmCoreModel.Instance.GetString(false)));
addressType.AddProperty(new EdmStructuralProperty(addressType, "City", EdmCoreModel.Instance.GetString(false)));
addressType.AddProperty(new EdmStructuralProperty(addressType, "PostalCode", EdmCoreModel.Instance.GetString(false)));
model.AddElement(addressType);
var companyType = new EdmEntityType(ns, "Company");
var companyId = new EdmStructuralProperty(companyType, "CompanyID", EdmCoreModel.Instance.GetInt32(false));
companyType.AddProperty(companyId);
companyType.AddKeys(companyId);
companyType.AddProperty(new EdmStructuralProperty(companyType, "Name", EdmCoreModel.Instance.GetString(true)));
companyType.AddProperty(new EdmStructuralProperty(companyType, "Address", new EdmComplexTypeReference(addressType, true)));
companyType.AddProperty(new EdmStructuralProperty(companyType, "Revenue", EdmCoreModel.Instance.GetInt32(false)));
model.AddElement(companyType);
var companySet = new EdmEntitySet(defaultContainer, "CompanySet", companyType);
defaultContainer.AddElement(companySet);
var companyEmployeeNavigation = companyType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo()
{
Name = "Employees",
Target = personType,
TargetMultiplicity = EdmMultiplicity.Many
});
companySet.AddNavigationTarget(companyEmployeeNavigation, largetPersonSet);
// ResetDataSource
var resetDataSourceAction = new EdmAction(ns, "ResetDataSource", null, false, null);
model.AddElement(resetDataSourceAction);
defaultContainer.AddActionImport(resetDataSourceAction);
return model;
}
示例11: DeltaLinkWriterIntegrationTests
static DeltaLinkWriterIntegrationTests()
{
Model = new EdmModel();
EntityType = new EdmEntityType("TestNamespace", "TestEntityType");
Model.AddElement(EntityType);
var keyProperty = new EdmStructuralProperty(EntityType, "ID", EdmCoreModel.Instance.GetInt32(false));
EntityType.AddKeys(new IEdmStructuralProperty[] { keyProperty });
EntityType.AddProperty(keyProperty);
var resourceNavigationProperty = EntityType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo { Name = "ResourceNavigationProperty", Target = EntityType, TargetMultiplicity = EdmMultiplicity.ZeroOrOne });
var resourceSetNavigationProperty = EntityType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo { Name = "ResourceSetNavigationProperty", Target = EntityType, TargetMultiplicity = EdmMultiplicity.Many });
var defaultContainer = new EdmEntityContainer("TestNamespace", "DefaultContainer");
Model.AddElement(defaultContainer);
EntitySet = new EdmEntitySet(defaultContainer, "TestEntitySet", EntityType);
EntitySet.AddNavigationTarget(resourceNavigationProperty, EntitySet);
EntitySet.AddNavigationTarget(resourceSetNavigationProperty, EntitySet);
defaultContainer.AddElement(EntitySet);
}
示例12: SegmentKeyHandlerTests
public SegmentKeyHandlerTests()
{
var typeWithStringKey = new EdmEntityType("NS.Foo", "TypeWithStringKey");
var originalType = new EdmEntityType("NS.Foo", "SourceType");
var keyProp = typeWithStringKey.AddStructuralProperty("KeyProp", EdmPrimitiveTypeKind.String);
typeWithStringKey.AddKeys(keyProp);
var multipleResultsWithSingleKeyNavProp = originalType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo() { Name = "NavProp", Target = typeWithStringKey, TargetMultiplicity = EdmMultiplicity.Many });
this.singleResultSegmentWithSingleKey = new NavigationPropertySegment(HardCodedTestModel.GetPersonMyDogNavProp(), null) { SingleResult = true };
this.multipleResultSegmentWithSingleKey = new NavigationPropertySegment(multipleResultsWithSingleKeyNavProp, null) { SingleResult = false };
this.multipleResultSegmentWithCompositeKey = new NavigationPropertySegment(HardCodedTestModel.GetPersonMyLionsNavProp(), null) { SingleResult = false };
}
示例13: ODataEntryMetadataContextTest
static ODataEntryMetadataContextTest()
{
ActualEntityType = new EdmEntityType("ns", "TypeName");
ActualEntityType.AddKeys(new IEdmStructuralProperty[] {ActualEntityType.AddStructuralProperty("ID2", EdmPrimitiveTypeKind.Int32), ActualEntityType.AddStructuralProperty("ID3", EdmPrimitiveTypeKind.Int32)});
ActualEntityType.AddStructuralProperty("Name2", EdmCoreModel.Instance.GetString(isNullable:true), /*defaultValue*/null, EdmConcurrencyMode.Fixed);
ActualEntityType.AddStructuralProperty("Name3", EdmCoreModel.Instance.GetString(isNullable: true), /*defaultValue*/null, EdmConcurrencyMode.Fixed);
ActualEntityType.AddStructuralProperty("StreamProp1", EdmPrimitiveTypeKind.Stream);
ActualEntityType.AddStructuralProperty("StreamProp2", EdmPrimitiveTypeKind.Stream);
var navProp1 = ActualEntityType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo()
{
Target = ActualEntityType,
TargetMultiplicity = EdmMultiplicity.Many,
Name = "NavProp1"
});
var navProp2 = ActualEntityType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo()
{
Target = ActualEntityType,
TargetMultiplicity = EdmMultiplicity.ZeroOrOne,
Name = "NavProp2"
});
var container = new EdmEntityContainer("Namespace", "Container");
EdmEntitySet entitySet = container.AddEntitySet("EntitySet", ActualEntityType);
entitySet.AddNavigationTarget(navProp1, entitySet);
entitySet.AddNavigationTarget(navProp2, entitySet);
Action1 = new EdmAction("Namespace", "Action1", null, true /*isBound*/, null /*entitySetPath*/);
Action2 = new EdmAction("Namespace", "Action2", null, true /*isBound*/, null /*entitySetPath*/);
ActionImport1 = new EdmActionImport(container, "ActionImport1", Action1);
ActionImport2 = new EdmActionImport(container, "ActionImport2", Action2);
Function1 = new EdmFunction("Namespace", "Function1", EdmCoreModel.Instance.GetString(isNullable: true), true /*isBound*/, null /*entitySetPath*/, true /*isComposable*/);
Function2 = new EdmFunction("Namespace", "Function2", EdmCoreModel.Instance.GetString(isNullable: true), true /*isBound*/, null /*entitySetPath*/, true /*isComposable*/);
FunctionImport1 = new EdmFunctionImport(container, "FunctionImport1", Function1);
FunctionImport2 = new EdmFunctionImport(container, "FunctionImport2", Function2);
}
示例14: Initialize
public void Initialize()
{
this.edmModel = new EdmModel();
this.defaultContainer = new EdmEntityContainer("TestModel", "DefaultContainer");
this.edmModel.AddElement(this.defaultContainer);
this.townType = new EdmEntityType("TestModel", "Town");
this.edmModel.AddElement(townType);
EdmStructuralProperty townIdProperty = townType.AddStructuralProperty("Id", EdmCoreModel.Instance.GetInt32(/*isNullable*/false));
townType.AddKeys(townIdProperty);
townType.AddStructuralProperty("Name", EdmCoreModel.Instance.GetString(/*isNullable*/false));
townType.AddStructuralProperty("Size", EdmCoreModel.Instance.GetInt32(/*isNullable*/false));
this.cityType = new EdmEntityType("TestModel", "City", this.townType);
cityType.AddStructuralProperty("Photo", EdmCoreModel.Instance.GetStream(/*isNullable*/false));
this.edmModel.AddElement(cityType);
this.districtType = new EdmEntityType("TestModel", "District");
EdmStructuralProperty districtIdProperty = districtType.AddStructuralProperty("Id", EdmCoreModel.Instance.GetInt32(/*isNullable*/false));
districtType.AddKeys(districtIdProperty);
districtType.AddStructuralProperty("Zip", EdmCoreModel.Instance.GetInt32(/*isNullable*/false));
districtType.AddStructuralProperty("Thumbnail", EdmCoreModel.Instance.GetStream(/*isNullable*/false));
this.edmModel.AddElement(districtType);
cityType.AddBidirectionalNavigation(
new EdmNavigationPropertyInfo { Name = "Districts", Target = districtType, TargetMultiplicity = EdmMultiplicity.Many },
new EdmNavigationPropertyInfo { Name = "City", Target = cityType, TargetMultiplicity = EdmMultiplicity.One });
this.defaultContainer.AddEntitySet("Cities", cityType);
this.defaultContainer.AddEntitySet("Districts", districtType);
this.metropolisType = new EdmEntityType("TestModel", "Metropolis", this.cityType);
this.metropolisType.AddStructuralProperty("MetropolisStream", EdmCoreModel.Instance.GetStream(/*isNullable*/false));
this.edmModel.AddElement(metropolisType);
metropolisType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo { Name = "MetropolisNavigation", Target = districtType, TargetMultiplicity = EdmMultiplicity.ZeroOrOne });
this.action = new EdmAction("TestModel", "Action", new EdmEntityTypeReference(this.cityType, true));
this.action.AddParameter("Param", EdmCoreModel.Instance.GetInt32(false));
this.edmModel.AddElement(action);
this.actionImport = new EdmActionImport(this.defaultContainer, "Action", action);
this.actionConflictingWithPropertyName = new EdmAction("TestModel", "Zip", new EdmEntityTypeReference(this.districtType, true));
this.actionConflictingWithPropertyName.AddParameter("Param", EdmCoreModel.Instance.GetInt32(false));
this.edmModel.AddElement(actionConflictingWithPropertyName);
this.actionImportConflictingWithPropertyName = new EdmActionImport(this.defaultContainer, "Zip", actionConflictingWithPropertyName);
this.openType = new EdmEntityType("TestModel", "OpenCity", this.cityType, false, true);
}
示例15: SimpleCustomerOrderModel
public static IEdmModel SimpleCustomerOrderModel()
{
var model = new EdmModel();
var customerType = new EdmEntityType("Default", "Customer");
customerType.AddStructuralProperty("ID", EdmPrimitiveTypeKind.Int32);
customerType.AddStructuralProperty("FirstName", EdmPrimitiveTypeKind.String);
customerType.AddStructuralProperty("LastName", EdmPrimitiveTypeKind.String);
IEdmTypeReference primitiveTypeReference = EdmCoreModel.Instance.GetPrimitive(
EdmPrimitiveTypeKind.String,
isNullable: true);
customerType.AddStructuralProperty(
"City",
primitiveTypeReference,
defaultValue: null,
concurrencyMode: EdmConcurrencyMode.Fixed);
model.AddElement(customerType);
var orderType = new EdmEntityType("Default", "Order");
orderType.AddStructuralProperty("ID", EdmPrimitiveTypeKind.Int32);
orderType.AddStructuralProperty("Name", EdmPrimitiveTypeKind.String);
orderType.AddStructuralProperty("Shipment", EdmPrimitiveTypeKind.String);
model.AddElement(orderType);
var addressType = new EdmComplexType("Default", "Address");
addressType.AddStructuralProperty("Street", EdmPrimitiveTypeKind.String);
addressType.AddStructuralProperty("City", EdmPrimitiveTypeKind.String);
addressType.AddStructuralProperty("State", EdmPrimitiveTypeKind.String);
addressType.AddStructuralProperty("Country", EdmPrimitiveTypeKind.String);
addressType.AddStructuralProperty("ZipCode", EdmPrimitiveTypeKind.String);
model.AddElement(addressType);
// Add navigations
customerType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo() { Name = "Orders", Target = orderType, TargetMultiplicity = EdmMultiplicity.Many });
orderType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo() { Name = "Customer", Target = customerType, TargetMultiplicity = EdmMultiplicity.One });
// Add Entity set
var container = new EdmEntityContainer("Default", "Container");
var customerSet = container.AddEntitySet("Customers", customerType);
var orderSet = container.AddEntitySet("Orders", orderType);
customerSet.AddNavigationTarget(customerType.NavigationProperties().Single(np => np.Name == "Orders"), orderSet);
orderSet.AddNavigationTarget(orderType.NavigationProperties().Single(np => np.Name == "Customer"), customerSet);
NavigationSourceLinkBuilderAnnotation linkAnnotation = new MockNavigationSourceLinkBuilderAnnotation();
model.SetNavigationSourceLinkBuilder(customerSet, linkAnnotation);
model.SetNavigationSourceLinkBuilder(orderSet, linkAnnotation);
model.AddElement(container);
return model;
}