PLINQO is the best way to use LINQ to SQL
LINQ to SQL is a great idea. It's a fast and easy way to generate a data layer from your SQL schema. With just a few clicks, you can have entity classes generated that you can then query from a repository class (or however you roll).
But what happens when your schema changes? You have to drop your LINQ entities from the diagram and re-add them. Any customizations you have made will be lost. And there are some other pitfalls:
- Many-to-Many relationships are not supported
- All your entities are defined in a single, monstrous class
- You have to fetch records from the database just to delete or update them
- There is no built-in caching
I was griping about this and someone told me about PLINQO. PLINQO is a set of templates for CodeSmith. There are a couple videos you can watch on www.plinqo.com that explain how to use it. It's pretty easy! You can do the whole thing in under a minute. I had never used CodeSmith or even heard of PLINQO but I figured it all out from watching the videos a few times.
PLINQO offers:
- Many-to-Many support
- Entities get their own class files
- Changes to your SQL schema are magically preserved when you update your classes
- Deletes and updates are optimized
- You can detach and reattach entities
- You can generate astoria services for EASY use with jQuery ajax (sweet!)
- MUCH MORE
If you like LINQ to SQL but are looking for a way to overcome its shortcomings, PLINQO is definitely the way to go. I have been using it for several months now on multiple projects, and I am very happy with it!