Sunday, August 23, 2009

LINQ with WCF

There is something very important I want to say. I LOVE Microsoft. It has made my life as a programmer and DBA so FANTASTIC in so many ways that I just had to say it.

Latest discovery ... LINQ! Known about it since it came out but started using it now :) due to work on other ...cough ... java ... cough ... projects).

Anyways anyone wondering how LINQ can fit into your WCF client / server application.

Well for one:
  • Create a statefull service
  • Create a DataContext for each session. There is no theoratical limit on the number of DataContexts you can use. They are not the same as your traditional ORM. Infact to cancel a DB transaction you should set your DataContext to null or just forget about it :). The only time a trascation takes place is in the SubmitChanges() type functions which start ... carry out the changes ... and finish the transaction. (of course selects also do transactions but you get the idea)

Enjoy!

No comments:

Post a Comment