Scenario: User wants to have the urls like this: "http://.../Products/10/ExtendSupportDate" without the '(' and ')' for keys.<br /><br />I implemented a custom parser like below:<br /><br /> public class MyODataPathParser : ODataPathParser<br /> {<br /> public MyODataPathParser(IEdmModel model)<br /> : base(model)<br /> {<br /> }<br /><br /> protected internal override IEnumerable<string> ParseSegments(string relativePath)<br /> {<br /> return relativePath.Split('/').Where(sg => sg.Length > 0);<br /> }<br /> <br /> protected override ODataPathSegment ParseAtEntityCollection(ODataPathSegment previous, string segment)<br /> {<br /> //check if the segment is key, if yes modify the segment to the format that the default parser expects<br /> int key = -1;<br /> if (Int32.TryParse(segment, out key))<br /> {<br /> segment = "(" + segment + ")";<br /> }<br /><br /> return base.ParseAtEntityCollection(previous, segment);<br /> }<br /> }<br /><br />Overall writing a custom parser for my scenario was simple, but following are some observations:<br /><br />a. A user would need to understand that he has to override ParserAtEntityCollection for what I am doing above. But how would a user know that as someone needs to know about the internal logic?<br /><br />b. Should we have more documentation on the individual overridable methods like ParseAtEntity, ParseAtEntityCollection etc to mention what possible things that the method looks for? for example: ParseAtEntityCollections looks for key, then cast and then bindable actions.
Comments: Please make sure we have good doc for the overload. We might need to add a virtual method for this common case.
Comments: Please make sure we have good doc for the overload. We might need to add a virtual method for this common case.