本文整理汇总了C#中EntityInstanceContext.GenerateSelfLink方法的典型用法代码示例。如果您正苦于以下问题:C# EntityInstanceContext.GenerateSelfLink方法的具体用法?C# EntityInstanceContext.GenerateSelfLink怎么用?C# EntityInstanceContext.GenerateSelfLink使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EntityInstanceContext
的用法示例。
在下文中一共展示了EntityInstanceContext.GenerateSelfLink方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateSelfLink_GeneratesExpectedSelfLink
public void GenerateSelfLink_GeneratesExpectedSelfLink(bool includeCast, string expectedIdLink)
{
HttpRequestMessage request = GetODataRequest(_model.Model);
var serializerContext = new ODataSerializerContext { Model = _model.Model, EntitySet = _model.Customers, Url = request.GetUrlHelper() };
var entityContext = new EntityInstanceContext(serializerContext, _model.SpecialCustomer.AsReference(), new { ID = 42 });
string idLink = entityContext.GenerateSelfLink(includeCast);
Assert.Equal(expectedIdLink, idLink);
}
示例2: GenerateSelfLink_WorksToGenerateExpectedSelfLink_ForSingleton
public void GenerateSelfLink_WorksToGenerateExpectedSelfLink_ForSingleton(bool includeCast, string expectedIdLink)
{
// Arrange
HttpRequestMessage request = GetODataRequest(_model.Model);
var serializerContext = new ODataSerializerContext { Model = _model.Model, NavigationSource = _model.Mary, Url = request.GetUrlHelper() };
var entityContext = new EntityInstanceContext(serializerContext, _model.SpecialCustomer.AsReference(), new { ID = 42 });
// Act
var idLink = entityContext.GenerateSelfLink(includeCast);
// Assert
Assert.Equal(expectedIdLink, idLink.ToString());
}
示例3: GenerateNavigationLink_WorksToGenerateExpectedNavigationLink_ForNonContainedNavigation
public void GenerateNavigationLink_WorksToGenerateExpectedNavigationLink_ForNonContainedNavigation()
{
// Arrange
IEdmEntityType myOrder = (IEdmEntityType)_model.Model.FindDeclaredType("NS.MyOrder");
IEdmNavigationProperty orderLinesProperty = myOrder.NavigationProperties().Single(x => x.Name.Equals("NonContainedOrderLines"));
var serializerContext = new ODataSerializerContext
{
Model = _model.Model,
NavigationSource = _model.OrderLines,
Path = new ODataPath(
new EntitySetPathSegment(_model.Model.FindDeclaredEntitySet("MyOrders")),
new KeyValuePathSegment("42"),
new NavigationPathSegment(orderLinesProperty),
new KeyValuePathSegment("21")),
Url = GetODataRequest(_model.Model).GetUrlHelper(),
};
var entityContext = new EntityInstanceContext(serializerContext, _model.OrderLine.AsReference(), new { ID = 21 });
// Act
Uri uri = entityContext.GenerateSelfLink(false);
// Assert
Assert.Equal("http://localhost/OrderLines(21)", uri.AbsoluteUri);
}