public static ODataPath Translate(this ODataPathTemplate pathTemplate) { if (pathTemplate.Count == 0) { // It's service root, so far, let's skip it. return(null); } IList <ODataSegment> newSegments = new List <ODataSegment>(); foreach (var segment in pathTemplate) { switch (segment.Kind) { case ODataSegmentKind.Metadata: newSegments.Add(new ODataMetadataSegment()); break; case ODataSegmentKind.EntitySet: EntitySetSegmentTemplate entitySet = (EntitySetSegmentTemplate)segment; newSegments.Add(entitySet.ConvertTo()); break; case ODataSegmentKind.Singleton: SingletonSegmentTemplate singleton = (SingletonSegmentTemplate)segment; newSegments.Add(singleton.ConvertTo()); break; case ODataSegmentKind.Key: KeySegmentTemplate key = (KeySegmentTemplate)segment; newSegments.Add(key.ConvertTo()); break; case ODataSegmentKind.Cast: CastSegmentTemplate cast = (CastSegmentTemplate)segment; newSegments.Add(cast.ConvertTo()); break; case ODataSegmentKind.Property: // TODO: return(null); //PropertySegmentTemplate property = (PropertySegmentTemplate)segment; //newSegments.Add(property.ConvertTo()); //break; case ODataSegmentKind.Navigation: NavigationSegmentTemplate navigation = (NavigationSegmentTemplate)segment; newSegments.Add(navigation.ConvertTo()); break; case ODataSegmentKind.Function: FunctionSegmentTemplate function = (FunctionSegmentTemplate)segment; newSegments.Add(function.ConvertTo()); break; case ODataSegmentKind.Action: ActionSegmentTemplate action = (ActionSegmentTemplate)segment; newSegments.Add(action.ConvertTo()); break; case ODataSegmentKind.FunctionImport: FunctionImportSegmentTemplate functionImport = (FunctionImportSegmentTemplate)segment; newSegments.Add(functionImport.ConvertTo()); break; case ODataSegmentKind.ActionImport: ActionImportSegmentTemplate actionImport = (ActionImportSegmentTemplate)segment; newSegments.Add(actionImport.ConvertTo()); break; case ODataSegmentKind.Value: return(null); //ValueSegmentTemplate value = (ValueSegmentTemplate)segment; //newSegments.Add(value.ConvertTo()); //break; case ODataSegmentKind.Ref: return(null); //KeySegmentTemplate key = (KeySegmentTemplate)segment; //newSegments.Add(key.ConvertTo()); //break; case ODataSegmentKind.NavigationLink: return(null); //NavigationLinkSegmentTemplate navigationLink = (NavigationLinkSegmentTemplate)segment; //newSegments.Add(navigationLink.ConvertTo()); //break; case ODataSegmentKind.Count: CountSegmentTemplate count = (CountSegmentTemplate)segment; newSegments.Add(count.ConvertTo()); break; case ODataSegmentKind.PathTemplate: return(null); //KeySegmentTemplate key = (KeySegmentTemplate)segment; //newSegments.Add(key.ConvertTo()); //break; case ODataSegmentKind.Dynamic: return(null); //KeySegmentTemplate key = (KeySegmentTemplate)segment; //newSegments.Add(key.ConvertTo()); //break; default: throw new NotSupportedException(); } } return(new ODataPath(newSegments)); }