public ClassA Get(string key) { key = key.Trim('\''); var item = TestRepo.GetAs().FirstOrDefault(a => key.Equals(a.Name)); return(item); }
public EdmEntityObjectCollection Get() { var props = Request.ODataProperties(); var model = Request.GetModel(); var es = (EntitySetSegment)props.Path.Segments[0]; var entityType = es.EntitySet.EntityType(); var collectionType = new EdmCollectionType(new EdmEntityTypeReference(entityType, false)); var queryContext = new ODataQueryContext(model, entityType, props.Path); var queryOptions = new ODataQueryOptions(queryContext, Request); int n; n = int.TryParse( Request.GetQueryNameValuePairs().Where(kv => kv.Key == "n").Select(kv => kv.Value).FirstOrDefault(), out n) ? n : 10; var @as = TestRepo.GetAs(n); if (queryOptions.SelectExpand != null) { props.SelectExpandClause = queryOptions.SelectExpand.SelectExpandClause; } return(new EdmEntityObjectCollection(new EdmCollectionTypeReference(collectionType), @as.Select(a => Map(model, a)).ToArray())); }
public IEnumerable <ClassA> Get() { int n; n = int.TryParse( Request.GetQueryNameValuePairs().Where(kv => kv.Key == "n").Select(kv => kv.Value).FirstOrDefault(), out n) ? n : 10; return(TestRepo.GetAs(n)); }