本文整理汇总了C#中IEdmModel.GetEdmTypeReference方法的典型用法代码示例。如果您正苦于以下问题:C# IEdmModel.GetEdmTypeReference方法的具体用法?C# IEdmModel.GetEdmTypeReference怎么用?C# IEdmModel.GetEdmTypeReference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEdmModel
的用法示例。
在下文中一共展示了IEdmModel.GetEdmTypeReference方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ODataEntityDeserializerTests
public ODataEntityDeserializerTests()
{
_edmModel = EdmTestHelpers.GetModel();
IEdmEntitySet entitySet = _edmModel.EntityContainers().Single().FindEntitySet("Products");
_readContext = new ODataDeserializerContext
{
Path = new ODataPath(new EntitySetPathSegment(entitySet)),
Model = _edmModel
};
_productEdmType = _edmModel.GetEdmTypeReference(typeof(Product)).AsEntity();
_supplierEdmType = _edmModel.GetEdmTypeReference(typeof(Supplier)).AsEntity();
_deserializerProvider = new DefaultODataDeserializerProvider();
}
示例2: ODataDeltaFeedSerializerTests
public ODataDeltaFeedSerializerTests()
{
_model = SerializationTestsHelpers.SimpleCustomerOrderModel();
_customerSet = _model.EntityContainer.FindEntitySet("Customers");
_model.SetAnnotationValue(_customerSet.EntityType(), new ClrTypeAnnotation(typeof(Customer)));
_path = new ODataPath(new EntitySetPathSegment(_customerSet));
_customers = new[] {
new Customer()
{
FirstName = "Foo",
LastName = "Bar",
ID = 10,
},
new Customer()
{
FirstName = "Foo",
LastName = "Bar",
ID = 42,
}
};
_deltaFeedCustomers = new EdmChangedObjectCollection(_customerSet.EntityType());
EdmDeltaEntityObject newCustomer = new EdmDeltaEntityObject(_customerSet.EntityType());
newCustomer.TrySetPropertyValue("ID", 10);
newCustomer.TrySetPropertyValue("FirstName", "Foo");
_deltaFeedCustomers.Add(newCustomer);
_customersType = _model.GetEdmTypeReference(typeof(Customer[])).AsCollection();
_writeContext = new ODataSerializerContext() { NavigationSource = _customerSet, Model = _model, Path = _path };
}
示例3: GetEdmType
public IEdmTypeReference GetEdmType(Type clrType, IEdmModel model)
{
IEdmTypeReference edmType;
if (!_cache.TryGetValue(clrType, out edmType))
{
edmType = model.GetEdmTypeReference(clrType);
_cache[clrType] = edmType;
}
return edmType;
}
示例4: ODataEntityTypeSerializerTests
public ODataEntityTypeSerializerTests()
{
_model = SerializationTestsHelpers.SimpleCustomerOrderModel();
_model.SetAnnotationValue<ClrTypeAnnotation>(_model.FindType("Default.Customer"), new ClrTypeAnnotation(typeof(Customer)));
_model.SetAnnotationValue<ClrTypeAnnotation>(_model.FindType("Default.Order"), new ClrTypeAnnotation(typeof(Order)));
_model.SetAnnotationValue(
_model.FindType("Default.SpecialCustomer"),
new ClrTypeAnnotation(typeof(SpecialCustomer)));
_model.SetAnnotationValue(
_model.FindType("Default.SpecialOrder"),
new ClrTypeAnnotation(typeof(SpecialOrder)));
_customerSet = _model.EntityContainer.FindEntitySet("Customers");
_customer = new Customer()
{
FirstName = "Foo",
LastName = "Bar",
ID = 10,
};
_orderSet = _model.EntityContainer.FindEntitySet("Orders");
_order = new Order
{
ID = 20,
};
_serializerProvider = new DefaultODataSerializerProvider();
_customerType = _model.GetEdmTypeReference(typeof(Customer)).AsEntity();
_orderType = _model.GetEdmTypeReference(typeof(Order)).AsEntity();
_specialCustomerType = _model.GetEdmTypeReference(typeof(SpecialCustomer)).AsEntity();
_specialOrderType = _model.GetEdmTypeReference(typeof(SpecialOrder)).AsEntity();
_serializer = new ODataEntityTypeSerializer(_serializerProvider);
_path = new ODataPath(new EntitySetPathSegment(_customerSet));
_writeContext = new ODataSerializerContext() { NavigationSource = _customerSet, Model = _model, Path = _path };
_entityInstanceContext = new EntityInstanceContext(_writeContext, _customerSet.EntityType().AsReference(), _customer);
}
示例5: ODataEntityTypeSerializerTests
public ODataEntityTypeSerializerTests()
{
_model = SerializationTestsHelpers.SimpleCustomerOrderModel();
_model.SetAnnotationValue<ClrTypeAnnotation>(_model.FindType("Default.Customer"), new ClrTypeAnnotation(typeof(Customer)));
_model.SetAnnotationValue<ClrTypeAnnotation>(_model.FindType("Default.Order"), new ClrTypeAnnotation(typeof(Order)));
_customerSet = _model.FindDeclaredEntityContainer("Default.Container").FindEntitySet("Customers");
_customer = new Customer()
{
FirstName = "Foo",
LastName = "Bar",
ID = 10,
};
_serializerProvider = new DefaultODataSerializerProvider();
_customerType = _model.GetEdmTypeReference(typeof(Customer)).AsEntity();
_serializer = new ODataEntityTypeSerializer(_serializerProvider);
_writeContext = new ODataSerializerContext() { EntitySet = _customerSet, Model = _model };
_entityInstanceContext = new EntityInstanceContext(_writeContext, _customerSet.ElementType.AsReference(), _customer);
}
示例6: ODataFeedSerializerTests
public ODataFeedSerializerTests()
{
_model = SerializationTestsHelpers.SimpleCustomerOrderModel();
_customerSet = _model.EntityContainer.FindEntitySet("Customers");
_model.SetAnnotationValue(_customerSet.EntityType(), new ClrTypeAnnotation(typeof(Customer)));
_customers = new[] {
new Customer()
{
FirstName = "Foo",
LastName = "Bar",
ID = 10,
},
new Customer()
{
FirstName = "Foo",
LastName = "Bar",
ID = 42,
}
};
_customersType = _model.GetEdmTypeReference(typeof(Customer[])).AsCollection();
_writeContext = new ODataSerializerContext() { NavigationSource = _customerSet, Model = _model };
}
示例7: GetExpectedPayloadType
internal static IEdmTypeReference GetExpectedPayloadType(Type type, ODataPath path, IEdmModel model)
{
IEdmTypeReference expectedPayloadType = null;
if (typeof(IEdmObject).IsAssignableFrom(type))
{
// typeless mode. figure out the expected payload type from the OData Path.
IEdmType edmType = path.EdmType;
if (edmType != null)
{
expectedPayloadType = EdmLibHelpers.ToEdmTypeReference(edmType, isNullable: false);
if (expectedPayloadType.TypeKind() == EdmTypeKind.Collection)
{
IEdmTypeReference elementType = expectedPayloadType.AsCollection().ElementType();
if (elementType.IsEntity())
{
// collection of entities cannot be CREATE/UPDATEd. Instead, the request would contain a single entry.
expectedPayloadType = elementType;
}
}
}
}
else
{
TryGetInnerTypeForDelta(ref type);
expectedPayloadType = model.GetEdmTypeReference(type);
}
return expectedPayloadType;
}
示例8: ODataFeedDeserializerTest
public ODataFeedDeserializerTest()
{
_model = GetEdmModel();
_customerType = _model.GetEdmTypeReference(typeof(Customer)).AsEntity();
_customersType = new EdmCollectionTypeReference(new EdmCollectionType(_customerType));
}
示例9: GetEntityType
private static IEdmEntityTypeReference GetEntityType(IEdmModel model, object entity)
{
Type entityType = entity.GetType();
IEdmTypeReference edmType = model.GetEdmTypeReference(entityType);
if (edmType == null)
{
throw Error.InvalidOperation(SRResources.EntityTypeNotInModel, entityType.FullName);
}
if (!edmType.IsEntity())
{
throw Error.InvalidOperation(SRResources.TypeMustBeEntity, edmType.FullName());
}
return edmType.AsEntity();
}