3

Are there any examples on using JayData with WebAPI ? Its not OData, but just a set of endpoints:

/api/Projects /api/users /api/something

I am just looking for a simple solution to get my webapi data to the client and send it back when changed for updating the backend. If there are other tools that work better with WebAPI im fine with that.

Poul K. Sørensen
  • 16,950
  • 21
  • 126
  • 283
  • So you are not planning to add some metadata services? – Peter Aron Zentai Nov 05 '12 at 08:10
  • I dont know. Until now I feel im using time on nothing. I see how metadata is nice when you have a big project and dont want to typeset objects on the client. It might just be that i need the right tool for creating the meta data. My issue with the metadata is from what I have seen, it maps the dbcontext. I would like to create custom WebAPI and not just let a client query a dbcontext. 1) There might be fields i dont want to send to the client. – Poul K. Sørensen Nov 05 '12 at 08:51

2 Answers2

3

we are about to release the JayData ItemStore API that let's you connect to OData endpoints without an actual OData metadata service, ideal for WebAPI.

I try to submit you an example here today...

UPDATE: Well, a month have passed, but finally, here is the example: WebAPI with JayData - 1st session

Peter Aron Zentai
  • 11,482
  • 5
  • 41
  • 71
  • 1
    Sounds cool :) I decided to start out with breezejs for now, but I will see what you come up with. – Poul K. Sørensen Nov 05 '12 at 08:48
  • Let me get this straight: so you are fine using the WebAPI metadata generator that is I guess the part of BreezeJS? In this case we are cool. Next monday we release a compatibility module so on top of BreezeJS fine metadata generator you can use the full set of JayData magic, like JSLQ. – Peter Aron Zentai Nov 06 '12 at 01:44
  • Im looking forward to seeing it. I used a few hours today digging into the Microsoft.Data.OData packaged and my experience was that it was not just a few lines to get it up and running - but it looked like it was pretty configurable. BreezeJs have a really easy to setup system on the backend - but from what i know now, its not easy to configure what data to expose toclients. (But i came to think of, i can always define a new DbContext that reflects data for different contexts. I looked into your ItemStore API, it looks simple. What i miss is some simple examples of get/edit/store on sever. – Poul K. Sørensen Nov 06 '12 at 01:59
  • This is actually how we deal with data on the server side but with WCF Data Services. Since we use codefirst, we can have different models for the same db. One for automatic internet publishing and the other for full internal access. Automatic publishing if done on the right model is not eval - quite the contrary: we need only one central place: the EDMX to manage what fields get out. Is fairly visual, and opting in/out fields ALWAYS have the risk of a mistake. Also note, that WCF Data service + jaydata support Service operations: these are methods that can influence the actual queryable – Peter Aron Zentai Nov 06 '12 at 09:54
  • and can act as a virtual table or view, much like how WebAPI actually works - but with the added bonus I can have automatic CRUD if I want to, and I can have fully controlled executions as well. – Peter Aron Zentai Nov 06 '12 at 09:56
  • Looking forward to that example :) – jonperl Dec 05 '12 at 22:31
  • At this point to do full CRUD we have a dependency on the Microsoft WebAPI OData extension so that the actual wire format that comes out from WebAPI is OData compliant. If you only wish to use pure WebAPI and nothing else you'll only be able to create new objects, and query for things with all potential - at this point update and delete object needs tweeking in the routing. Which approach is interesting for you? btw I am sharing the pure WebAPI approach right now - should be ready by morning :) it the night is long enough. – Peter Aron Zentai Dec 06 '12 at 18:39
  • well actually full crud and query capabilities are now working with editor generated default web api controllers. No need for stinking metadata. At this point you can update with PUT (no merge, full instance has to be sent). I finish some unit tests - have some sleep than make this available from the JayData CDN and blog. – Peter Aron Zentai Dec 07 '12 at 02:06
  • And here it is: http://jaydata.org/blog/how-to-use-jaydata-with-asp.net-web-api---i – Peter Aron Zentai Dec 10 '12 at 15:57
0

web api odata package added support to build your own $metadata. please install the package from Install-Package Microsoft.Data.OData.Contrib -Pre.

ODataModelBuilder can build model explicitly, while ODataConventionModelBuilder provides a more convenient way to build model based conventions like recognizing DataMember attibutes.

Please check the blog and the sample

Hongye Sun
  • 3,868
  • 1
  • 25
  • 18