本文整理汇总了C#中System.Net.Http.HttpRequestMessage.GetSelectExpandClause方法的典型用法代码示例。如果您正苦于以下问题:C# HttpRequestMessage.GetSelectExpandClause方法的具体用法?C# HttpRequestMessage.GetSelectExpandClause怎么用?C# HttpRequestMessage.GetSelectExpandClause使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Net.Http.HttpRequestMessage
的用法示例。
在下文中一共展示了HttpRequestMessage.GetSelectExpandClause方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetSelectClause
private static string GetSelectClause(HttpRequestMessage request)
{
Contract.Assert(request != null);
if (request.GetSelectExpandClause() != null)
{
// Include the $select clause only if it has been applied.
IEnumerable<KeyValuePair<string, string>> queryOptions = request.GetQueryNameValuePairs();
return queryOptions.Where(kvp => kvp.Key == "$select").Select(kvp => kvp.Value).FirstOrDefault();
}
return null;
}
示例2: GetSelectExpandClause_Returns_SetSelectExpandClause
public void GetSelectExpandClause_Returns_SetSelectExpandClause()
{
// Arrange
HttpRequestMessage request = new HttpRequestMessage();
SelectExpandClause selectExpandCaluse = GetMockSelectExpandClause();
// Act
request.SetSelectExpandClause(selectExpandCaluse);
var result = request.GetSelectExpandClause();
// Assert
Assert.Same(selectExpandCaluse, result);
}
示例3: ApplyTo_SetsRequestSelectExpandClause_IfSelectExpandIsNotNull
public void ApplyTo_SetsRequestSelectExpandClause_IfSelectExpandIsNotNull()
{
// Arrange
var model = new ODataModelBuilder().Add_Customers_EntitySet().GetEdmModel();
var request = new HttpRequestMessage(HttpMethod.Get, new Uri("http://server/service/Customers?$select=Name"));
ODataQueryOptions queryOptions = new ODataQueryOptions(new ODataQueryContext(model, typeof(Customer)), request);
// Act
queryOptions.ApplyTo(Enumerable.Empty<Customer>().AsQueryable());
// Assert
Assert.NotNull(request.GetSelectExpandClause());
}
示例4: GetSelectExpandClause_ReturnsNullByDefault
public void GetSelectExpandClause_ReturnsNullByDefault()
{
HttpRequestMessage request = new HttpRequestMessage();
Assert.Null(request.GetSelectExpandClause());
}