本文整理汇总了C#中Microsoft.OData.Edm.Library.EdmEntitySet类的典型用法代码示例。如果您正苦于以下问题:C# EdmEntitySet类的具体用法?C# EdmEntitySet怎么用?C# EdmEntitySet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EdmEntitySet类属于Microsoft.OData.Edm.Library命名空间,在下文中一共展示了EdmEntitySet类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ODataFeedAndEntryTypeContextTests
static ODataFeedAndEntryTypeContextTests()
{
Model = new EdmModel();
EntitySetElementType = new EdmEntityType("ns", "Customer");
ExpectedEntityType = new EdmEntityType("ns", "VipCustomer", EntitySetElementType);
ActualEntityType = new EdmEntityType("ns", "DerivedVipCustomer", ExpectedEntityType);
EdmEntityContainer defaultContainer = new EdmEntityContainer("ns", "DefaultContainer");
Model.AddElement(defaultContainer);
Model.AddVocabularyAnnotation(new EdmAnnotation(defaultContainer, UrlConventionsConstants.ConventionTerm, UrlConventionsConstants.KeyAsSegmentAnnotationValue));
EntitySet = new EdmEntitySet(defaultContainer, "Customers", EntitySetElementType);
Model.AddElement(EntitySetElementType);
Model.AddElement(ExpectedEntityType);
Model.AddElement(ActualEntityType);
defaultContainer.AddElement(EntitySet);
SerializationInfo = new ODataFeedAndEntrySerializationInfo { NavigationSourceName = "MyCustomers", NavigationSourceEntityTypeName = "ns.MyCustomer", ExpectedTypeName = "ns.MyVipCustomer" };
SerializationInfoWithEdmUnknowEntitySet = new ODataFeedAndEntrySerializationInfo() { NavigationSourceName = null, NavigationSourceEntityTypeName = "ns.MyCustomer", ExpectedTypeName = "ns.MyVipCustomer", NavigationSourceKind = EdmNavigationSourceKind.UnknownEntitySet };
TypeContextWithoutModel = ODataFeedAndEntryTypeContext.Create(SerializationInfo, navigationSource: null, navigationSourceEntityType: null, expectedEntityType: null, model: Model, throwIfMissingTypeInfo: true);
TypeContextWithModel = ODataFeedAndEntryTypeContext.Create(/*serializationInfo*/null, EntitySet, EntitySetElementType, ExpectedEntityType, Model, throwIfMissingTypeInfo: true);
TypeContextWithEdmUnknowEntitySet = ODataFeedAndEntryTypeContext.Create(SerializationInfoWithEdmUnknowEntitySet, navigationSource: null, navigationSourceEntityType: null, expectedEntityType: null, model: Model, throwIfMissingTypeInfo: true);
BaseTypeContextThatThrows = ODataFeedAndEntryTypeContext.Create(serializationInfo: null, navigationSource: null, navigationSourceEntityType: null, expectedEntityType: null, model: Model, throwIfMissingTypeInfo: true);
BaseTypeContextThatWillNotThrow = ODataFeedAndEntryTypeContext.Create(serializationInfo: null, navigationSource: null, navigationSourceEntityType: null, expectedEntityType: null, model: Model, throwIfMissingTypeInfo: false);
}
开发者ID:AlineGuan,项目名称:odata.net,代码行数:25,代码来源:ODataFeedAndEntryTypeContextTests.cs
示例2: EdmSingletonBasicNavigationPropertyBindingTest
public void EdmSingletonBasicNavigationPropertyBindingTest()
{
var internalOrderProperty = customerType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo(){Name = "InternalOrder", Target = this.orderType, TargetMultiplicity = EdmMultiplicity.ZeroOrOne});
var externalOrderProperty = customerType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo(){Name = "ExternalOrders", Target = this.orderType, TargetMultiplicity = EdmMultiplicity.Many});
var customerProductProperty = customerType.AddBidirectionalNavigation(
new EdmNavigationPropertyInfo() { Name = "Products", Target = this.productType, TargetMultiplicity = EdmMultiplicity.Many },
new EdmNavigationPropertyInfo() { Name = "Buyer", Target = this.customerType, TargetMultiplicity = EdmMultiplicity.One });
var orderSet = new EdmEntitySet(this.entityContainer, "Orders", this.orderType);
var productSet = new EdmEntitySet(this.entityContainer, "Products", this.productType);
var vipCustomer = new EdmSingleton(this.entityContainer, "VIP", this.customerType);
vipCustomer.NavigationPropertyBindings.Should().HaveCount(0);
vipCustomer.AddNavigationTarget(internalOrderProperty, orderSet);
vipCustomer.AddNavigationTarget(externalOrderProperty, orderSet);
vipCustomer.AddNavigationTarget(customerProductProperty, productSet);
vipCustomer.NavigationPropertyBindings.Should().HaveCount(3)
.And.Contain(m => m.NavigationProperty == internalOrderProperty && m.Target == orderSet)
.And.Contain(m => m.NavigationProperty == externalOrderProperty && m.Target == orderSet)
.And.Contain(m=>m.NavigationProperty == customerProductProperty && m.Target == productSet);
vipCustomer.FindNavigationTarget(internalOrderProperty).Should().Be(orderSet);
vipCustomer.FindNavigationTarget(externalOrderProperty).Should().Be(orderSet);
vipCustomer.FindNavigationTarget(customerProductProperty).Should().Be(productSet);
productSet.AddNavigationTarget(customerProductProperty.Partner, vipCustomer);
productSet.FindNavigationTarget(customerProductProperty.Partner).Should().Be(vipCustomer);
}
开发者ID:larsenjo,项目名称:odata.net,代码行数:32,代码来源:EdmSingletonTests.cs
示例3: CreateEntryWithKeyAsSegmentConvention
private static ODataEntry CreateEntryWithKeyAsSegmentConvention(bool addAnnotation, bool? useKeyAsSegment)
{
var model = new EdmModel();
var container = new EdmEntityContainer("Fake", "Container");
model.AddElement(container);
if (addAnnotation)
{
model.AddVocabularyAnnotation(new EdmAnnotation(container, UrlConventionsConstants.ConventionTerm, UrlConventionsConstants.KeyAsSegmentAnnotationValue));
}
EdmEntityType entityType = new EdmEntityType("Fake", "FakeType");
entityType.AddKeys(entityType.AddStructuralProperty("Id", EdmPrimitiveTypeKind.Int32));
model.AddElement(entityType);
var entitySet = new EdmEntitySet(container, "FakeSet", entityType);
container.AddElement(entitySet);
var metadataContext = new ODataMetadataContext(
true,
ODataReaderBehavior.DefaultBehavior.OperationsBoundToEntityTypeMustBeContainerQualified,
new EdmTypeReaderResolver(model, ODataReaderBehavior.DefaultBehavior),
model,
new Uri("http://temp.org/$metadata"),
null /*requestUri*/);
var thing = new ODataEntry {Properties = new[] {new ODataProperty {Name = "Id", Value = 1}}};
thing.SetAnnotation(new ODataTypeAnnotation(entitySet, entityType));
thing.MetadataBuilder = metadataContext.GetEntityMetadataBuilderForReader(new TestJsonLightReaderEntryState { Entry = thing, SelectedProperties = new SelectedPropertiesNode("*")}, useKeyAsSegment);
return thing;
}
开发者ID:larsenjo,项目名称:odata.net,代码行数:30,代码来源:KeyAsSegmentTemplateIntegrationTests.cs
示例4: 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);
}
开发者ID:larsenjo,项目名称:odata.net,代码行数:30,代码来源:InstanceAnnotationsReaderIntegrationTests.cs
示例5: GetEntitySetLinkBuilder_ReturnsDefaultEntitySetBuilder_IfNotSet
public void GetEntitySetLinkBuilder_ReturnsDefaultEntitySetBuilder_IfNotSet()
{
IEdmModel model = new EdmModel();
EdmEntityContainer container = new EdmEntityContainer("NS", "Container");
EdmEntityType entityType = new EdmEntityType("NS", "Entity");
IEdmEntitySet entitySet = new EdmEntitySet(container, "EntitySet", entityType);
Assert.NotNull(model.GetEntitySetLinkBuilder(entitySet));
}
开发者ID:tlycken,项目名称:aspnetwebstack,代码行数:9,代码来源:EdmModelExtensionsTest.cs
示例6: TestEntityType
public void TestEntityType()
{
var container = new EdmEntityContainer("NS", "C");
var entityType = new EdmEntityType("NS", "People");
var entitySet = new EdmEntitySet(container, "Peoples", entityType);
Assert.AreEqual(entityType, entitySet.EntityType());
var singleton = new EdmSingleton(container, "Boss", entityType);
Assert.AreEqual(entityType, singleton.EntityType());
}
开发者ID:larsenjo,项目名称:odata.net,代码行数:9,代码来源:ExtensionMethodsTests.cs
示例7: 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;
}
开发者ID:TomDu,项目名称:odata.net,代码行数:56,代码来源:PerfServiceEdmModel.cs
示例8: 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;
}
开发者ID:larsenjo,项目名称:odata.net,代码行数:56,代码来源:ODataSimplifiedInMemoryModel.cs
示例9: Initialize
public void Initialize()
{
this.model = new EdmModel();
EdmComplexType personalInfo = new EdmComplexType(MyNameSpace, "PersonalInfo");
personalInfo.AddStructuralProperty("Age", EdmPrimitiveTypeKind.Int16);
personalInfo.AddStructuralProperty("Email", EdmPrimitiveTypeKind.String);
personalInfo.AddStructuralProperty("Tel", EdmPrimitiveTypeKind.String);
personalInfo.AddStructuralProperty("ID", EdmPrimitiveTypeKind.Guid);
EdmComplexType derivedPersonalInfo = new EdmComplexType(MyNameSpace, "DerivedPersonalInfo", personalInfo);
derivedPersonalInfo.AddStructuralProperty("Hobby", EdmPrimitiveTypeKind.String);
EdmComplexType derivedDerivedPersonalInfo = new EdmComplexType(MyNameSpace, "DerivedDerivedPersonalInfo", derivedPersonalInfo);
derivedDerivedPersonalInfo.AddStructuralProperty("Education", EdmPrimitiveTypeKind.String);
EdmComplexType subjectInfo = new EdmComplexType(MyNameSpace, "Subject");
subjectInfo.AddStructuralProperty("Name", EdmPrimitiveTypeKind.String);
subjectInfo.AddStructuralProperty("Score", EdmPrimitiveTypeKind.Int16);
EdmComplexType derivedSubjectInfo = new EdmComplexType(MyNameSpace, "DerivedSubject", subjectInfo);
derivedSubjectInfo.AddStructuralProperty("Teacher", EdmPrimitiveTypeKind.String);
EdmComplexType derivedDerivedSubjectInfo = new EdmComplexType(MyNameSpace, "DerivedDerivedSubject", derivedSubjectInfo);
derivedDerivedSubjectInfo.AddStructuralProperty("Classroom", EdmPrimitiveTypeKind.String);
EdmCollectionTypeReference subjectsCollection = new EdmCollectionTypeReference(new EdmCollectionType(new EdmComplexTypeReference(subjectInfo, isNullable: true)));
studentInfo = new EdmEntityType(MyNameSpace, "Student");
studentInfo.AddStructuralProperty("Info", new EdmComplexTypeReference(personalInfo, isNullable: false));
studentInfo.AddProperty(new EdmStructuralProperty(studentInfo, "Subjects", subjectsCollection));
// enum with flags
var enumFlagsType = new EdmEnumType(MyNameSpace, "ColorFlags", isFlags: true);
enumFlagsType.AddMember("Red", new EdmIntegerConstant(1));
enumFlagsType.AddMember("Green", new EdmIntegerConstant(2));
enumFlagsType.AddMember("Blue", new EdmIntegerConstant(4));
studentInfo.AddStructuralProperty("ClothesColors", new EdmCollectionTypeReference(new EdmCollectionType(new EdmEnumTypeReference(enumFlagsType, true))));
EdmCollectionTypeReference hobbiesCollection = new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetString(isNullable: false)));
studentInfo.AddProperty(new EdmStructuralProperty(studentInfo, "Hobbies", hobbiesCollection));
model.AddElement(enumFlagsType);
model.AddElement(studentInfo);
model.AddElement(personalInfo);
model.AddElement(derivedPersonalInfo);
model.AddElement(derivedDerivedPersonalInfo);
model.AddElement(subjectInfo);
model.AddElement(derivedSubjectInfo);
model.AddElement(derivedDerivedSubjectInfo);
IEdmEntityContainer defaultContainer = new EdmEntityContainer("NS", "DefaultContainer");
model.AddElement(defaultContainer);
this.studentSet = new EdmEntitySet(defaultContainer, "MySet", this.studentInfo);
}
开发者ID:rossjempson,项目名称:odata.net,代码行数:56,代码来源:NonPrimitiveTypeRoundtripJsonLightTests.cs
示例10: GetNavigationSourceLinkBuilder_ReturnsDefaultNavigationSourceBuilder_IfNotSet
public void GetNavigationSourceLinkBuilder_ReturnsDefaultNavigationSourceBuilder_IfNotSet()
{
// Arrange
IEdmModel model = new EdmModel();
EdmEntityContainer container = new EdmEntityContainer("NS", "Container");
EdmEntityType entityType = new EdmEntityType("NS", "Entity");
IEdmNavigationSource navigationSource = new EdmEntitySet(container, "EntitySet", entityType);
// Act & Assert
Assert.NotNull(model.GetNavigationSourceLinkBuilder(navigationSource));
}
开发者ID:chinadragon0515,项目名称:WebApi,代码行数:11,代码来源:EdmModelExtensionsTest.cs
示例11: JsonFullMetadataLevelTests
static JsonFullMetadataLevelTests()
{
MetadataDocumentUri = new Uri("http://host/service.svc/$metadata", UriKind.Absolute);
referencedModel = new EdmModel();
EdmEntityContainer defaultContainer = new EdmEntityContainer("ns", "defaultContainer_sub");
EntityType = new EdmEntityType("ns", "EntityType");
EntitySet = new EdmEntitySet(defaultContainer, "Set", EntityType);
referencedModel.AddElement(defaultContainer);
Model = TestUtils.WrapReferencedModelsToMainModel("ns", "defaultContainer", referencedModel);
}
开发者ID:larsenjo,项目名称:odata.net,代码行数:11,代码来源:JsonFullMetadataLevelTests.cs
示例12: Init
public void Init()
{
var entityContainer = new EdmEntityContainer("MyNamespace", "MyThing");
var entityType = new EdmEntityType("MyNamespace", "EntityType");
entityType.AddKeys(new EdmStructuralProperty(entityType, "Id", EdmCoreModel.Instance.GetInt32(false)));
this.entitySet = this.entitySet = new EdmEntitySet(entityContainer, "EntitySet", entityType);
this.structure = new EdmStructuredValueSimulator(entityType, new Dictionary<string, IEdmValue> { { "Id", EdmValueUtils.ConvertPrimitiveValue(1, null).Value } });
this.metadataBuilder = new ConventionalODataEntityMetadataBuilder(new Uri("http://test/"), ((IEdmEntitySet)this.entitySet).Name, this.structure, DataServiceUrlConventions.Default);
}
开发者ID:larsenjo,项目名称:odata.net,代码行数:12,代码来源:ConventionalEntityMetadataBuilderTests.cs
示例13: EnsureActionImportIsAddedAndWithCorrectEntitySetExpression
public void EnsureActionImportIsAddedAndWithCorrectEntitySetExpression()
{
EdmEntityContainer container = new EdmEntityContainer("Default", "Container");
EdmAction action = new EdmAction("DS", "TestAction", EdmCoreModel.Instance.GetBoolean(false));
var edmEntitySet = new EdmEntitySet(container, "EntitySet", new EdmEntityType("DS", "TestEntity"));
var entitySetExpression = new EdmEntitySetReferenceExpression(edmEntitySet);
var actionImport = container.AddActionImport("OtherName", action, entitySetExpression);
actionImport.Action.Should().Be(action);
actionImport.Name.Should().Be("OtherName");
actionImport.EntitySet.Should().Be(entitySetExpression);
container.Elements.ToArray()[0].Should().Be(actionImport);
}
开发者ID:larsenjo,项目名称:odata.net,代码行数:13,代码来源:EdmEntityContainerTests.cs
示例14: CreateErrorTestModel
//// TODO: Add in-stream error tests
/// <summary>
/// Creates an empty model so that the JSON lite serializer won't complain.
/// </summary>
/// <param name="entitySet">An entity set in the generated model.</param>
private EdmModel CreateErrorTestModel(out EdmEntitySet entitySet)
{
EdmModel model = new EdmModel();
var customer = new EdmEntityType("TestModel", "Customer");
model.AddElement(customer);
var container = new EdmEntityContainer("TestModel", "DefaultContainer");
model.AddElement(container);
entitySet = container.AddEntitySet("Customers", customer);
return model;
}
开发者ID:larsenjo,项目名称:odata.net,代码行数:20,代码来源:WriterErrorTests.cs
示例15: GetNavigationSourceLinkBuilder_After_SetNavigationSourceLinkBuilder_OnEntitySet
public void GetNavigationSourceLinkBuilder_After_SetNavigationSourceLinkBuilder_OnEntitySet()
{
// Arrange
IEdmModel model = new EdmModel();
EdmEntityContainer container = new EdmEntityContainer("NS", "Container");
EdmEntityType entityType = new EdmEntityType("NS", "Entity");
IEdmEntitySet entitySet = new EdmEntitySet(container, "EntitySet", entityType);
NavigationSourceLinkBuilderAnnotation linkBuilder = new NavigationSourceLinkBuilderAnnotation();
// Act
model.SetNavigationSourceLinkBuilder(entitySet, linkBuilder);
var result = model.GetNavigationSourceLinkBuilder(entitySet);
// Assert
Assert.Same(linkBuilder, result);
}
开发者ID:chinadragon0515,项目名称:WebApi,代码行数:16,代码来源:EdmModelExtensionsTest.cs
示例16: ODataAtomReaderEnumIntegrationTests
public ODataAtomReaderEnumIntegrationTests()
{
this.userModel = new EdmModel();
// enum without flags
var enumType = new EdmEnumType("NS", "Color");
var red = new EdmEnumMember(enumType, "Red", new EdmIntegerConstant(1));
enumType.AddMember(red);
enumType.AddMember("Green", new EdmIntegerConstant(2));
enumType.AddMember("Blue", new EdmIntegerConstant(3));
this.userModel.AddElement(enumType);
// enum with flags
var enumFlagsType = new EdmEnumType("NS", "ColorFlags", isFlags: true);
enumFlagsType.AddMember("Red", new EdmIntegerConstant(1));
enumFlagsType.AddMember("Green", new EdmIntegerConstant(2));
enumFlagsType.AddMember("Blue", new EdmIntegerConstant(4));
this.userModel.AddElement(enumFlagsType);
this.entityType = new EdmEntityType("NS", "MyEntityType", isAbstract: false, isOpen: true, baseType: null);
EdmStructuralProperty floatId = new EdmStructuralProperty(this.entityType, "FloatId", EdmCoreModel.Instance.GetSingle(false));
this.entityType.AddKeys(floatId);
this.entityType.AddProperty(floatId);
var enumTypeReference = new EdmEnumTypeReference(enumType, true);
this.entityType.AddProperty(new EdmStructuralProperty(this.entityType, "Color", enumTypeReference));
var enumFlagsTypeReference = new EdmEnumTypeReference(enumFlagsType, false);
this.entityType.AddProperty(new EdmStructuralProperty(this.entityType, "ColorFlags", enumFlagsTypeReference));
// enum in complex type
EdmComplexType myComplexType = new EdmComplexType("NS", "MyComplexType");
myComplexType.AddProperty(new EdmStructuralProperty(myComplexType, "MyColorFlags", enumFlagsTypeReference));
myComplexType.AddProperty(new EdmStructuralProperty(myComplexType, "Height", EdmCoreModel.Instance.GetDouble(false)));
this.userModel.AddElement(myComplexType);
this.entityType.AddProperty(new EdmStructuralProperty(this.entityType, "MyComplexType", new EdmComplexTypeReference(myComplexType, true)));
// enum in collection type
EdmCollectionType myCollectionType = new EdmCollectionType(enumFlagsTypeReference);
this.entityType.AddProperty(new EdmStructuralProperty(this.entityType, "MyCollectionType", new EdmCollectionTypeReference(myCollectionType)));
this.userModel.AddElement(this.entityType);
var defaultContainer = new EdmEntityContainer("NS", "DefaultContainer");
this.entitySet = new EdmEntitySet(defaultContainer, "MySet", this.entityType);
defaultContainer.AddEntitySet(this.entitySet.Name, this.entityType);
this.userModel.AddElement(defaultContainer);
}
开发者ID:larsenjo,项目名称:odata.net,代码行数:46,代码来源:ODataAtomReaderEnumIntegrationTests.cs
示例17: 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);
}
开发者ID:rossjempson,项目名称:odata.net,代码行数:19,代码来源:DeltaLinkWriterIntegrationTests.cs
示例18: EnumFilterFunctionalTests
public EnumFilterFunctionalTests()
{
// set up the edm model etc
this.userModel = new EdmModel();
var enumType = new EdmEnumType("NS", "Color", EdmPrimitiveTypeKind.Int32, false);
var red = new EdmEnumMember(enumType, "Red", new EdmIntegerConstant(1));
enumType.AddMember(red);
enumType.AddMember("Green", new EdmIntegerConstant(2));
enumType.AddMember("Blue", new EdmIntegerConstant(3));
enumType.AddMember("White", new EdmIntegerConstant(-10));
// add to model
this.userModel.AddElement(enumType);
// add enum property
this.entityType = new EdmEntityType("NS", "MyEntityType", isAbstract: false, isOpen: true, baseType: null);
var enumTypeReference = new EdmEnumTypeReference(enumType, true);
this.entityType.AddProperty(new EdmStructuralProperty(this.entityType, "Color", enumTypeReference));
// enum with flags
var enumFlagsType = new EdmEnumType("NS", "ColorFlags", EdmPrimitiveTypeKind.Int64, true);
enumFlagsType.AddMember("Red", new EdmIntegerConstant(1L));
enumFlagsType.AddMember("Green", new EdmIntegerConstant(2L));
enumFlagsType.AddMember("Blue", new EdmIntegerConstant(4L));
enumFlagsType.AddMember("GreenRed", new EdmIntegerConstant(3L));
// add to model
this.userModel.AddElement(enumFlagsType);
// add enum with flags
var enumFlagsTypeReference = new EdmEnumTypeReference(enumFlagsType, true);
this.entityType.AddProperty(new EdmStructuralProperty(this.entityType, "ColorFlags", enumFlagsTypeReference));
this.userModel.AddElement(this.entityType);
var defaultContainer = new EdmEntityContainer("NS", "DefaultContainer");
this.userModel.AddElement(defaultContainer);
this.entitySet = new EdmEntitySet(defaultContainer, "MySet", this.entityType);
defaultContainer.AddElement(this.entitySet);
}
开发者ID:larsenjo,项目名称:odata.net,代码行数:42,代码来源:EnumFilterFunctionalTests.cs
示例19: ODataEntityReferenceLinksTests
static ODataEntityReferenceLinksTests()
{
EdmModel tmpModel = new EdmModel();
EdmComplexType complexType = new EdmComplexType("TestNamespace", "TestComplexType");
complexType.AddProperty(new EdmStructuralProperty(complexType, "StringProperty", EdmCoreModel.Instance.GetString(false)));
tmpModel.AddElement(complexType);
EntityType = new EdmEntityType("TestNamespace", "TestEntityType");
tmpModel.AddElement(EntityType);
var keyProperty = new EdmStructuralProperty(EntityType, "ID", EdmCoreModel.Instance.GetInt32(false));
EntityType.AddKeys(new IEdmStructuralProperty[] { keyProperty });
EntityType.AddProperty(keyProperty);
var defaultContainer = new EdmEntityContainer("TestNamespace", "DefaultContainer_sub");
tmpModel.AddElement(defaultContainer);
EntitySet = new EdmEntitySet(defaultContainer, "Customers", EntityType);
defaultContainer.AddElement(EntitySet);
EdmModel = TestUtils.WrapReferencedModelsToMainModel("TestNamespace", "DefaultContainer", tmpModel);
MessageReaderSettingsReadAndValidateCustomInstanceAnnotations = new ODataMessageReaderSettings { ShouldIncludeAnnotation = ODataUtils.CreateAnnotationFilter("*") };
}
开发者ID:vebin,项目名称:odata.net,代码行数:21,代码来源:ODataEntityReferenceLinksTests.cs
示例20: VerifyAnnotationComputedConcurrency
public void VerifyAnnotationComputedConcurrency()
{
var model = new EdmModel();
var entity = new EdmEntityType("NS1", "Product");
var entityId = entity.AddStructuralProperty("Id", EdmCoreModel.Instance.GetInt32(false));
entity.AddKeys(entityId);
EdmStructuralProperty name1 = entity.AddStructuralProperty("Name", EdmCoreModel.Instance.GetString(false));
EdmStructuralProperty timeVer = entity.AddStructuralProperty("UpdatedTime", EdmCoreModel.Instance.GetDate(false));
model.AddElement(entity);
SetComputedAnnotation(model, entityId); // semantic meaning is V3's 'Identity' for Key profperty
SetComputedAnnotation(model, timeVer); // semantic meaning is V3's 'Computed' for non-key profperty
var entityContainer = new EdmEntityContainer("NS1", "Container");
model.AddElement(entityContainer);
EdmEntitySet set1 = new EdmEntitySet(entityContainer, "Products", entity);
model.SetOptimisticConcurr
|
请发表评论