I have an asp.net web app which holds its data in an sql server 08 r2 db.
I have a silverlight admin interface on the same web app, and I will have a win forms app which will need to add/retrieve data from the sql db. Is there a way I can use linq in both clients?
开发者_Go百科I mean something like linq2twitter, where in the silverlight or in winforms app I can use linq to query and update the data.
Currently Im thinking of just using web services, but the data objects are complicated and they're connected to so many other data objects, it would be very convenient to work with them in linq, especially because the asp.net app itself uses a linq data context for its operations. Is there a way to expose this context over http or something?
Thanks
I think you probably want to look at WCF Data Services - which does pretty much exactly what you suggest i.e. it exposes a data context via web services (see also OData) and provides tools to consume and work with same via Linq
I tried WCF Data Services, its freaking amazing but it was a little hard to get up to speed with it, and difficult to diagnose what went wrong where, just for anyone else in my position here is what I did:
- I watched this really fun scott hanselman video on OData
- Landed on this msdn page after 1 hour of meandering. (Note all the snags like loading related entities, also, there is a list of unsupported linq operations on wcf ds)
- Went crazy looking for some examples.
- Tried my own stuff with lots of problems--> Got fiddler and then fixed all of them =)
Hope that helps!
精彩评论