-
Notifications
You must be signed in to change notification settings - Fork 476
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OData 6.0 How to have both UnqualifiedODataUriResolver and StringAsEnumResolver? #856
Comments
I managed to set-up a work-arround. Sample code is:
Maybe it would be good to make the class public, and add also this addition. |
Hi Mytza, thanks for providing the workaround. It will be great if you can also provide your solution to the global stackoverflow.com so that the OData community can benefit from this. |
Hi, |
If someone needs to use AlternateKeys along with UnqualifiedODataUriResolver. using Microsoft.OData.Edm;
using Microsoft.OData.UriParser;
using System;
using System.Collections.Generic;
namespace PBSWebServerAPI.Util
{
/// <summary>
/// Implementation for resolving the alternate keys and Resolver that supports bound function calls..
/// </summary>
public class CustomODataUriResolver : ODataUriResolver
{
/// <summary>
/// Model to be used for resolving the alternate keys.
/// </summary>
private readonly IEdmModel model;
private readonly AlternateKeysODataUriResolver alternateKeysODataUriResolver;
private readonly UnqualifiedODataUriResolver unqualifiedODataUriResolver;
public CustomODataUriResolver(IEdmModel model)
{
this.model = model;
alternateKeysODataUriResolver = new AlternateKeysODataUriResolver(model);
unqualifiedODataUriResolver = new UnqualifiedODataUriResolver();
}
#region Implementa AlternateKeysODataUriResolver
/// <summary>
/// Resolve keys for certain entity set, this function would be called when key is specified as name value pairs. E.g. EntitySet(ID='key')
/// </summary>
/// <param name="type">Type for current entityset.</param>
/// <param name="namedValues">The dictionary of name value pairs.</param>
/// <param name="convertFunc">The convert function to be used for value converting.</param>
/// <returns>The resolved key list.</returns>
public override IEnumerable<KeyValuePair<string, object>> ResolveKeys(IEdmEntityType type, IDictionary<string, string> namedValues, Func<IEdmTypeReference, string, object> convertFunc)
{
var result = alternateKeysODataUriResolver.ResolveKeys(type, namedValues, convertFunc);
return result;
}
#endregion
#region Implementa UnqualifiedODataUriResolver
/// <summary>
/// Resolve unbound operations based on name.
/// </summary>
/// <param name="model">The model to be used.</param>
/// <param name="identifier">The operation name.</param>
/// <returns>Resolved operation list.</returns>
public override IEnumerable<IEdmOperation> ResolveUnboundOperations(IEdmModel model, string identifier)
{
var result = unqualifiedODataUriResolver.ResolveUnboundOperations(model, identifier);
return result;
}
/// <summary>
/// Resolve bound operations based on name.
/// </summary>
/// <param name="model">The model to be used.</param>
/// <param name="identifier">The operation name.</param>
/// <param name="bindingType">The type operation was binding to.</param>
/// <returns>Resolved operation list.</returns>
public override IEnumerable<IEdmOperation> ResolveBoundOperations(IEdmModel model, string identifier, IEdmType bindingType)
{
var result = unqualifiedODataUriResolver.ResolveBoundOperations(model, identifier, bindingType);
return result;
}
#endregion
}
} |
Hi,
I am having problem enabling StringAsEnumResolver and UnqualifiedODataUriResolver.
Before migrating to Odata 6.0 i was using:
configuration.EnableUnqualifiedNameCall(true);
configuration.EnableEnumPrefixFree(true);
How can i achieve this with OData 6.0 ?
I tried:
But as both are of type ODataUriResolver, this is not working.
I looked in the unit tests but i couldn't find any example.
Thanks in advance,
Mihai
The text was updated successfully, but these errors were encountered: