Giter VIP home page Giter VIP logo

odatasamples's Introduction

OData Samples

Build Status
Rolling

Introduction

This project is for OData V4 samples on .NET, including sample services, sample clients and others.

Components Demo

URIParser

/Components/URIParser

Writer

/Components/Writer

Scenarios Demo

Sample services Web API Implementation

Please check at /Scenarios/TripPin/src/webapi

Community

Issue tracker

To report bugs and require features, please use our issue tracker.

Mailing list

For more questions about TripPin and OData, please use the OData Mailling List

odatasamples's People

Contributors

bdebaere avatar biaol-odata avatar challenh avatar chinadragon0515 avatar chrisrichner avatar congysu avatar davidsimner avatar dependabot[bot] avatar g2mula avatar gathogojr avatar icnocop avatar jspuij avatar kanishmanuja-ms avatar karataliu avatar kenitoinc avatar lewischeng-ms avatar liqian19891011 avatar madansr7 avatar mikepizzo avatar mirsking avatar mumbi-o avatar robward-ms avatar subhankars avatar tiano2017 avatar tomdu avatar vikingsfan avatar viktor-evdokimov avatar wanjohisammy avatar xuzhg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

odatasamples's Issues

Only host one version of TripPin service on services.odata.org

We should retire the read-only version of TripPin as it doesn't add any value beyond the read/write version of TripPin. Also, while we will presumably implement over a stack, I am not convinced that services.odata.org is the right place to host multiple variants of TripPin so we should build the sample service on the stack that allows us to implement the most important/requested features and not worry about hosting the same service multiple times. This means we only need one TripPin service, not a read TripPin service over ODL, a read/write TripPin service over ODL, and a read/write TripPin service over Web API OData.

So:

  1. Retire the read-only service, and
  2. Choose between ODL and Web API OData and only host one version of TripPin

Note: the stack supporting the reference service can change over time, but there's just not a compelling case to support the same reference service over multiple stacks.

Error on ODataCompositeKeySample

I'm having trouble using the example approach provided for composite primary keys.

To be as brief as possible, the problem is apparently in this line of code.

RouteValues.ContainsKey (ODataRouteConstants.Key)

The above line works correctly while the url is for a resource that does not have a compound key, because in this Array / Collection there is an entry like "key", but when the resource to be searched has a composite key, The "key" is separated into two or more entries in the array, which of course are not called "key", instead they are called "key {FiledKeyName}".

Am I doing something wrong? Or was there any update that the Example is not up to date?

If further details are needed, please let me know.

Victor Perez

$count propertie not working

I have a service in OdataV4 and *_$count *_property is not working as described in the specifications, returns this mesage -. "The query specified in the URI is not valid 'with' expected at position 46 in 'groupby ((Medico / Pk_distrito) , aggregate ($count the NumReceitas)) '. "

Sample services don't support CORS, which makes JS clients hard to consume

The original issue is here: OData/odataorg.github.io#66

Quoting the author:

And thus can not be used from a web browser for testing JS, for instance.
Example request:

OPTIONS http://services.odata.org/V3/Northwind/Northwind.svc/$metadata HTTP/1.1
Accept: */*
Origin: http://localhost:50854
Access-Control-Request-Method: GET
Access-Control-Request-Headers: accept, maxdataserviceversion
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko
Host: services.odata.org
Content-Length: 0
DNT: 1
Connection: Keep-Alive
Pragma: no-cache
MaxDataServiceVersion: 3.0

and it's response:

HTTP/1.1 501 Not Implemented
Cache-Control: private
Content-Length: 195
Content-Type: application/xml;charset=utf-8
Expires: Thu, 30 Jul 2015 18:31:03 GMT
Vary: *
Server: Microsoft-IIS/8.0
X-Content-Type-Options: nosniff
DataServiceVersion: 1.0;
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET
Access-Control-Allow-Headers: Accept, Origin, Content-Type, MaxDataServiceVersion
Access-Control-Expose-Headers: DataServiceVersion

Notice the response headers claim to allow CORS, but the response is Not Implemented.

Workaround

None that I know. I'd tipically just uso JSONP, but $metadata can not be requested by JSONP.

The reporter was able to reproduce this problem against V2, V3 and V4 Northwind services. He hasn't tested TripPin services yet, but they may have the same problem.

Add Date and TimeOfDay type

[From Vlad Filyakov]
Looking at the data represented by the Trip objects, I wonder if StartsAt and EndsAt properties should have a new Date type instead of DateTimeOffset (all the time zone values have zero time)? It would also help to showcase new features of OData v4. Right now the TripPin service has an example of Duration, but nothing for Date and TimeOfDay.

NOTES:
Date, TimeOfDay not supported in Web API OData yet but now supported in ODL
Modify the data behind ODL to add time zone values to StartsAt and EndsAt

AdventureWorksLTSample not working with latest NuGet packages

Steps to duplicate:

  1. Download the AdventureWorksLTSample
  2. Build. Build works.
  3. Remove all previous NuGet packages
    get-package | uninstall-package -force
  4. Install updated NuGet packages
    install-package Microsoft.Restier
  5. Build. Build fails.

It looks like the issues are in the WebApiConfig.cs as some objects no longer exist.

Is 'Trips' NavigationProperty on 'Person' EntityType' a containment navigation property ?

There is no EntitySet corresponding to the EntityType 'Trip'. So I believe in order to add a trip for a person, we need to send to POST request to the Trips's url through person. e.g.

POST /People('russellwhyte')/Trips

This is how we add a record for containment navigation property.
According to OData v4 spec (http://docs.oasis-open.org/odata/odata/v4.0/errata03/os/complete/part3-csdl/odata-v4.0-errata03-os-part3-csdl-complete.html#_Toc453752542), ContainsTarget should be true for a containment navigation property. ContainsTarget also isn't set for Trips navigation property.

Is it a containment navigation property ?

Proposal: Delete unnecessary PropertyValue elements

You can delete unnecessary PropertyValue elements like

<PropertyValue Property="NonInsertableNavigationProperties">
                                  <Collection/>
</PropertyValue>

in several places. We wrote in the specifications “For collection-valued properties the absence of an edm:PropertyValue child element is equivalent to specifying a child element with an empty collection as its value.”, see http://docs.oasis-open.org/odata/odata/v4.0/errata01/os/complete/part3-csdl/odata-v4.0-errata01-os-part3-csdl-complete.html#_Toc395268278

TripPin- Filter on People/Trips/PlanItems produces an InternalServerError for some entities

ODL TripPinService (not web api TripPinService) @ http://services.odata.org/V4/TripPinService


Hi

This works fine:

http://services.odata.org/V4/TripPinService/People('russellwhyte')/Trips(0)/PlanItems?$filter=contains(ConfirmationCode,%27JH%27)

and this one generates an exception:

http://services.odata.org/V4/TripPinService/People('russellwhyte')/Trips(1003)/PlanItems?$filter=contains(ConfirmationCode,%27JH%27)

{
• error: {
• code: "InternalServerError",
• message: "Object reference not set to an instance of an object.",
• innererror: {
• message: "Object reference not set to an instance of an object.",
• type: "System.NullReferenceException",
• stacktrace:
" at lambda_method(Closure , PlanItem )
at System.Linq.Enumerable.WhereEnumerableIterator1.MoveNext() at System.Linq.Enumerable.<SkipIterator>d__4d1.MoveNext()
at System.Linq.Enumerable.Count[TSource](IEnumerable`1 source)
at Microsoft.Test.OData.Services.ODataWCFService.QueryContext.ProcessQueryResult(Object originalResult)
at Microsoft.Test.OData.Services.ODataWCFService.QueryContext.ResolveQuery(IODataDataSource dataSource, Int32 level)
at Microsoft.Test.OData.Services.ODataWCFService.Handlers.QueryHandler.Process(IODataRequestMessage requestMessage, IODataResponseMessage responseMessage)
at Microsoft.Test.OData.Services.ODataWCFService.Handlers.RequestHandler.Process(Stream requestStream)
at Microsoft.Test.OData.Services.ODataWCFService.Handlers.RootRequestHandler.Process(Stream requestStream)"

}
}
}

The only difference is that filter is applied to Trips(0) in the first case and to Trips(1003) in the second.

Thanks,
Vlad

Unable to check / call TransientAction

HI,

I Have an Odata V4 Controller setup and i am using TransientAction to express if i an action can be eecuted in the current state so i dont have to have duplicated code in client and server.

This works fine with angular and js in general.

i can do:

var actionLink= item['#Action'];;
if (!actionLink) {
return;
}
$http.post(actionLink.target, {});
....

I didnt find a way to do that with odata client as the proxy generator does not map functions in the objects.

i found OperationDescriptions on the EntityDescription but they are always present.

can anyone help me with this issue?

btw. its a little ugly to only be able to call actions with an extension on DataServiceQuerySingle.

why isnt the selflink and all the other selfdocumentation ( editlink etc. )only available via entityDescriptor and not part of each object?

Query option apply

Hi
I have a requirement of retrieving data from database dynamically based on API methods. For which i got the sample code from stack overflow for the same code mentioned in Github.

https://stackoverflow.com/questions/29981931/dynamic-odata-service-in-c-sharp-from-runtime-data-layer

But it doesn't show or suggest how to apply the Filter options.Sample code mentioned below

public EdmEntityObjectCollection Get()
{
// get Edm type from request
ODataPath path = Request.ODataProperties().Path; // ODataProperties() needs using System.Web.OData.Extensions
IEdmType edmType = path.EdmType;

    IEdmCollectionType collectionType = (IEdmCollectionType)edmType;
    IEdmEntityType entityType = (IEdmEntityType)collectionType.ElementType.Definition;
    IEdmModel model = Request.ODataProperties().Model;

    ODataQueryContext queryContext = new ODataQueryContext(model, entityType, path);
    ODataQueryOptions queryOptions = new ODataQueryOptions(queryContext, Request);

    // TODO: apply the query option on the IQueryable here.
    // read all rows from table (could be optimized using query context)

    var table = (DatabaseTable)ControllerContext.ControllerDescriptor.Properties["table"];
    var cnx = (string)ControllerContext.ControllerDescriptor.Properties["connectionString"];
    var data = ReadData(entityType, table, cnx);

    var a = queryOptions.ApplyTo(data.AsQueryable());


    return new EdmEntityObjectCollection(new EdmCollectionTypeReference(collectionType), data);
}

Any help on this will be much appreciated

expand multiple levels example

requesting http://services.odata.org/v4/TripPinServiceRW/People('russellwhyte')?$expand=Friends
expands Russels friends as expected, but trying to expand Russels Friends Trips with the following request
http://services.odata.org/v4/TripPinServiceRW/People('russellwhyte')?$expand=Friends/Trips
results in

{
    "error": {
        "code": "BadRequest",
        "message": "Found a path traversing multiple navigation properties. Please rephrase the query such that each expand path contains only type segments and navigation properties.",
        "innererror": {
            "message": "Found a path traversing multiple navigation properties. Please rephrase the query such that each expand path contains only type segments and navigation properties.",
            "type": "Microsoft.Test.OData.Services.ODataWCFService.ODataServiceException",
            "stacktrace": "   at Microsoft.Test.OData.Services.ODataWCFService.QueryContext.get_QuerySelectExpandClause()\r\n   at Microsoft.Test.OData.Services.ODataWCFService.Handlers.RequestHandler.GetWriterSettings()\r\n   at Microsoft.Test.OData.Services.ODataWCFService.Handlers.RequestHandler.CreateMessageWriter(IODataResponseMessage message)\r\n   at Microsoft.Test.OData.Services.ODataWCFService.Handlers.QueryHandler.Process(IODataRequestMessage requestMessage, IODataResponseMessage responseMessage)\r\n   at Microsoft.Test.OData.Services.ODataWCFService.Handlers.RequestHandler.Process(Stream requestStream)\r\n   at Microsoft.Test.OData.Services.ODataWCFService.Handlers.RootRequestHandler.Process(Stream requestStream)",
            "internalexception": {
                "message": "Found a path traversing multiple navigation properties. Please rephrase the query such that each expand path contains only type segments and navigation properties.",
                "type": "Microsoft.OData.Core.ODataException",
                "stacktrace": "   at Microsoft.OData.Core.UriParser.Parsers.SelectExpandBinder.GenerateExpandItem(ExpandTermToken tokenIn)\r\n   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()\r\n   at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()\r\n   at System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection)\r\n   at Microsoft.OData.Core.UriParser.Parsers.SelectExpandBinder.Bind(ExpandToken tokenIn)\r\n   at Microsoft.OData.Core.UriParser.Parsers.SelectExpandSemanticBinder.Bind(IEdmStructuredType elementType, IEdmNavigationSource navigationSource, ExpandToken expandToken, SelectToken selectToken, ODataUriParserConfiguration configuration)\r\n   at Microsoft.OData.Core.UriParser.ODataQueryOptionParser.ParseSelectAndExpandImplementation(String select, String expand, ODataUriParserConfiguration configuration, IEdmStructuredType elementType, IEdmNavigationSource navigationSource)\r\n   at Microsoft.OData.Core.UriParser.ODataQueryOptionParser.ParseSelectAndExpand()\r\n   at Microsoft.OData.Core.UriParser.ODataUriParser.ParseSelectAndExpand()\r\n   at Microsoft.Test.OData.Services.ODataWCFService.QueryContext.get_QuerySelectExpandClause()"
            }
        }
    }
}

Is there any working multilevel expand example out there, or am I just getting $expand wrong?

Incorrect $count system query option behaviour on TripPin?

According to OData documentation "The $count system query option ignores any $top, $skip, or $expand query options", but in TripPin those query options are taken into account when returning "@odata.count". E.g.

http://services.odata.org/V4/TripPinService/People?$top=2&$count=true => returns "@odata.count": 2
http://services.odata.org/V4/TripPinService/People?$skip=2&$count=true => returns "@odata.count":22 (in the "skip" example it is returning the total elements in the list minus the skip value ~ 24 - 2)

Does not contain definition for filter

I am trying one of the samples and getting following error
Severity Code Description Project File Line Suppression State
Error CS1061 'HttpConfiguration' does not contain a definition for 'Filter' and no extension method 'Filter' accepting a first argument of type 'HttpConfiguration' could be found (are you missing a using directive or an assembly reference?)

Corrections are necessary for the Entityset definition of People and for the Singleton Me; the navigationPropertyBindings are partly incorrect.

The corrected NavigationPropertyBindings are (if TripPin is defined as an alias fro the schema namespace):

         <NavigationPropertyBinding Path="Friends" Target="People"/>
          <NavigationPropertyBinding Path="Trips/PlanItems/TripPin.Flight/Airline" Target="Airlines"/>
          <NavigationPropertyBinding Path="Trips/PlanItems/TripPin.Flight/From" Target="Airports"/>
          <NavigationPropertyBinding Path="Trips/PlanItems/TripPin.Flight/To" Target="Airports"/>
          <NavigationPropertyBinding Path="Trips/Photos" Target="Photos"/>
          <NavigationPropertyBinding Path="Photo" Target="Photos"/>

Thanks
Martin

OData V4 $entity is not supported

OData V4 $entity does not work.
According to the specs,

http://services.odata.org/V4/TripPinServiceRW/$entity?$id=People%28%27russellwhyte%27%29

Should return an entity reference. Instead, you get this error:
{"error":{"code":"NotFound","message":"Resource not found for the segment '$entity'.","innererror":{"message":"Resource not found for the segment '$entity'.","type":"Microsoft.OData.Core.UriParser.ODataUnrecognizedPathException","stacktrace":" at Microsoft.OData.Core.UriParser.Parsers.ODataPathParser.ParsePath(ICollection1 segments)\r\n at Microsoft.OData.Core.UriParser.Parsers.ODataPathFactory.BindPath(ICollection1 segments, ODataUriParserConfiguration configuration)\r\n at Microsoft.OData.Core.UriParser.ODataUriParser.ParsePathImplementation()\r\n at Microsoft.OData.Core.UriParser.ODataUriParser.Initialize()\r\n at Microsoft.Test.OData.Services.ODataWCFService.Handlers.QueryHandler.DispatchHandler()\r\n at Microsoft.Test.OData.Services.ODataWCFService.Handlers.RequestHandler.Process(Stream requestStream)\r\n at Microsoft.Test.OData.Services.ODataWCFService.Handlers.RootRequestHandler.Process(Stream requestStream)"}}}

ODataEtagSample doesn't work when the Model contains a double

I took the ODataEtagSample and changed the Customer Version from an int to a double. Now when I run this example it blows up with the message

The response status code is InternalServerError
{
"error": {
"code": "",
"message": "An error has occurred.",
"innererror": {
"message": "The binary operator Equal is not defined for the types 'System
.Double' and 'System.Int32'.",
"type": "System.InvalidOperationException",
"stacktrace": " at System.Linq.Expressions.Expression.GetEqualityComparisonOperator(ExpressionType binaryType, String opName, Expression left, Expression right, Boolean liftToNull)\r\n at System.Linq.Expressions.Expression.Equal(Expression left, Expression right, Boolean liftToNull, MethodInfo method)\r\n at System.Linq.Expressions.Expression.Equal(Expression left, Expression right)\r\n at System.Web.OData.Formatter.ETag.ApplyTo(IQueryable query)\r\n at System.Web.OData.Formatter.ETag1.ApplyTo(IQueryable1 query)\r\n at ODataEtagSample.Controllers.CustomersController.Get(Int32 key, ODataQueryOptions1 options) in C:\\Users\\ccraigp1\\Source\\Workspaces\\ODataSamples-master\\WebApi\\v4\\ODataEtagSample\\ODataEtagSample\\Controllers\\CustomersController.cs:line 22\r\n at lambda_method(Closure , Object , Object[] )\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary2 arguments, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter1.GetResult()\r\n at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter1.GetResult()\r\n at System.Web.Http.Filters.ActionFilterAttribute.CallOnActionExecutedAsync>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Web.Http.Filters.ActionFilterAttribute.d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter1.GetResult()\r\n at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0.MoveNext()\r\n---End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter1.GetResult()\r\n at System.Web.Http.Controllers.ActionFilterResult.d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.d__1.MoveNext()"
}
}
}

I tried this because I was having a similar problem with my application.

Unable to build OdataUntypedSample when upgraded to odata v7

Hi,

I tried upgrading the odatauntypedsample project to odata libraries version 7 and i am getting build errors

Severity Code Description Project File Line Suppression State
Error CS0234 The type or namespace name 'Library' does not exist in the namespace 'Microsoft.OData.Edm' (are you missing an assembly reference?) ODataUntypedSample D:\Balu\Sgc\ODatav4 Sample\ODataSamples-master\WebApi\v4\ODataUntypedSample\ODataUntypedSample\Controllers\ProductsController.cs 8 Active

Severity Code Description Project File Line Suppression State
Error CS1061 'HttpRequestMessageProperties' does not contain a definition for 'Model' and no extension method 'Model' accepting a first argument of type 'HttpRequestMessageProperties' could be found (are you missing a using directive or an assembly reference?) ODataUntypedSample D:\Balu\Sgc\ODatav4 Sample\ODataSamples-master\WebApi\v4\ODataUntypedSample\ODataUntypedSample\Controllers\ProductsController.cs 41 Active

Is there any breaking change with OData Libraries version 7.

Thanks

namespace of NHibernateQueryableSample

System.Web.Http.OData.NHibernate could be System.Web.OData.NHibernate. Also the folder name /WebApi/v4/NHibernateQueryableSample/System.Web.Http.OData.NHibernate could be /WebApi/v4/NHibernateQueryableSample/System.Web.OData.NHibernate

/odata/Products?$expand=Category not working

HI!

In "ODataUntypedSample" project, when I tried to get the Product's as well as its Category by using "/odata/Products?$expand=Category" - it didn't return the Category records. Can anyone explain why... Is i am missing something?

[tried both "ODataUntypedSample" as well as "ODataUntypedSample6.x"]

Tag incoming PRs

Tag the PRs with labels:
PR_Team: PR submitted by OData team members.
PR_Internal: PR submitted by a colleague within Microsoft.
PR_External: PR submitted by a GitHub user outside of Microsoft.

Update Web API Trippin service to add more feature since V5.3

Trippin service is launched last year. Since then, many features added into Web API OData. For example:

  1. Complex Inheritance,
  2. Function/action enhancement
  3. Reference constraint.
    ...

Please find time to add these features into Trippin service. Thanks.

Proposal: Use ALIAS for references and the schema

For the references and for the schema itself please introduced aliases and used them in all places (get rid of the lengthy namespaces for qualified names), this makes the metadata document much more readable.

Unfortunately I can't upload a sample file here.

Cannot add functions to DynamicEdmModelCreation sample

I looked at OData function/action examples ODataActionsSample & ODataFunctionSample from https://github.com/OData/ODataSamples to learn how to add functions eg.

- we prefix functions with [HttpGet] in a ODataController class,
- in WebApiConfig::Register(), declare the function and add to the model

then calling functions via web URLs magically work!

However, the DynamicEdmModelCreation sample uses extremely different approach to adding controllers/datasources since it uses one controller called HandleAllController. and makes sure of helper classes:

CustomODataRoute
DynamicModelHelper

so I can't figure out how to add functions/actions to this project.

I've studied/debug and think there's something I need to do with MatchAllRoutingConvention::SelectAction()

if (odataPath.PathTemplate == "~/unboundfunction")
return "FunctionName";

But it says function not found.
Is there a proper way to add functions to DynamicEdmModelCreation sample project?

oData V4 case sensitive and incase sensitive is not working

`http://services.odata.org/V4/Northwind/Northwind.svc/Employees/?$filter=contains(toupper(FirstName),%27C%27)

http://services.odata.org/V4/Northwind/Northwind.svc/Employees/?$filter=contains(tolower(FirstName),%27C%27)`

this is query string but it always return both lower and uppercase

OData json formatter

Hi
for the lateset version is there any example on how to develop a serialization formatter ?
the examples in the repository seems to be outdated
thanks

Trip Pin service code does not match deployment at http://services.odata.org/V4/TripPinServiceRW

It looks like there has been some divergence between the sample code in https://github.com/OData/ODataSamples/tree/master/Scenarios/TripPin and the deployment of the sample service at http://services.odata.org/V4/TripPinServiceRW.

This is made more clear by comparing the metadata document obtained from a local deployment of master and the metadata document on the deployed example. The deployed document contains annotations which are not defined in the current sample code.

Keeping these in sync will help make this a better resource for people learning to use and implement OData services. The simplest fix is to push changes to this repository.

Does TripPin support OData-MaxVersion?

I just tried to make a few requests with Postman to the live TripPin service with OData-MaxVersion header set to different values... But the service seems to completely ignore it. Yet, this is a requirement of the Minimal Conformance Level:

In order to conform to the OData Minimal Conformance Level, a service MUST conform to the semantics the following headers, or fail the request

  • 5.1. Accept (section 8.2.1)
  • 5.2. OData-MaxVersion (section 8.2.7)

Error in $metadata

Using elements from namespaces not inlcued in the document requires the use auf edmx:reference.
You need to add as children of edmx:Edmx

<edmx:Reference Uri="http://docs.oasis-open.org/odata/odata/v4.0/os/vocabularies/Org.OData.Core.V1.xml">
    <edmx:Include Alias="Core" Namespace="Org.OData.Core.V1"/>
  </edmx:Reference>
  <edmx:Reference Uri="http://docs.oasis-open.org/odata/odata/v4.0/os/vocabularies/Org.OData.Capabilities.V1.xml">
    <edmx:Include Alias="Capabilities" Namespace="Org.OData.Capabilities.V1"/>
  </edmx:Reference>
  <edmx:Reference Uri="http://docs.oasis-open.org/odata/odata/v4.0/os/vocabularies/Org.OData.Measures.V1.xml">
    <edmx:Include Alias="Measures" Namespace="Org.OData.Measures.V1"/>
  </edmx:Reference>

The given model does not contain the type 'Provider.SDK.Contract.CustomValue'

'Provider.SDK.Contract.CustomValue' is a custom EdmComplexType。

The error message is :
"innererror": {
"message": "The given model does not contain the type 'Provider.SDK.Contract.CustomValue'.",
"type": "System.InvalidOperationException",
"stacktrace": "
at System.Web.OData.Formatter.Serialization.ODataSerializerContext.GetEdmType(Object instance, Type type)\r\n
at System.Web.OData.Formatter.Serialization.ODataResourceSerializer.GetResourceType(Object graph, ODataSerializerContext writeContext)\r\n
at System.Web.OData.Formatter.Serialization.ODataResourceSerializer.WriteResource(Object graph, ODataWriter writer, ODataSerializerContext writeContext, IEdmTypeReference expectedType)\r\n
at System.Web.OData.Formatter.Serialization.ODataResourceSerializer.WriteComplexProperties(IEnumerable`1 complexProperties, ResourceContext resourceContext, ODataWriter writer)\r\n
at System.Web.OData.Formatter.Serialization.ODataResourceSerializer.WriteResource(Object graph, ODataWriter writer, ODataSerializerContext writeContext, IEdmTypeReference expectedType)\r\n
at System.Web.OData.Formatter.Serialization.ODataResourceSetSerializer.WriteResourceSet(IEnumerable enumerable, IEdmTypeReference resourceSetType, ODataWriter writer, ODataSerializerContext writeContext)\r\n
at System.Web.OData.Formatter.ODataMediaTypeFormatter.WriteToStream(Type type, Object value, Stream writeStream, HttpContent content, HttpContentHeaders contentHeaders)\r\n
at System.Web.OData.Formatter.ODataMediaTypeFormatter.WriteToStreamAsync(Type type, Object value, Stream writeStream, HttpContent content, TransportContext transportContext, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n
at System.Web.Http.Owin.HttpMessageHandlerAdapter.d__13.MoveNext()"
}

Using attribute routing looks not possible using this way

If I have multi-tenant application with multiple models and I want to build these models dynamically and at the runtime route to appropriate controller and actions using Attribute routing, this looks impossible with the current way

Fix TripPin's status code, if a singleton nav prop is null

If a singleton nav prop is null, response status code should be 204, instead of 404:
http://services.odata.org/V4/(S(1bzgqcaqidqnywiq3nyevuxz))/TripPinServiceRW/People('javieralfred')/Photo

HTTP/1.1 404 Not Found
Connection: Keep-Alive
Content-Length: 600
Content-Type: application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8

{
  "error": {
    "code": "NotFound",
    "message": "An server side error occured.",
    "innererror": {
      "message": "An server side error occured.",
      "type": "Microsoft.Test.OData.Services.ODataWCFService.ODataServiceException",
      "stacktrace": "   at Microsoft.Test.OData.Services.ODataWCFService.Handlers.QueryHandler.Process(IODataRequestMessage requestMessage, IODataResponseMessage responseMessage)\r\n   at Microsoft.Test.OData.Services.ODataWCFService.Handlers.RequestHandler.Process(Stream requestStream)\r\n   at Microsoft.Test.OData.Services.ODataWCFService.Handlers.RootRequestHandler.Process(Stream requestStream)"
    }
  }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.