Practical .NET

Not Using LINQ Yet? Here's a Few Reasons Why.

Peter Vogel introduces a new column on application development in the real world, and begins by advocating for Language Integrated Query.

Microsoft and magazines like this one have been telling you to adopt LINQ and Entity Framework for what seems like years. The main reason that you haven't done so is, probably, because you're smart. Smart developers build up a body of what I call "programmer lore" -- all the knowledge that you accumulate while you build applications in a particular technology. This includes all the standard solutions you keep in your mental toolbox, the generalized code you use in multiple applications, the cut-and-paste code you move from one program to another, and more. Programmer lore is knowing what the compiler's error messages really mean.

When it comes to data access, you've probably built up a working knowledge of SQL -- you can pretty much get SQL to do what you need. You've probably assembled a personal toolkit with some combination of writing raw SQL, a graphical tool for building SQL and ADO.NET. Your fingers can probably automatically type out the five or eight lines of code to create and open a connection, define a command object, call the ExecReader method and loop through the retrieved records.

And you know that you'll need to learn a bunch of new stuff to really use LINQ. During that period your productivity will be reduced, but your deadlines won't change. Finally, there are surely things you'll want to do in LINQ that, currently, your fingers won't type out automatically.

I'm here to help. It's time to give up ADO.NET and SQL and commit to the potent combination of LINQ and Entity Framework. Instead of writing all that ADO.NET code, line by painful line, you'll declare what you want with LINQ, and LINQ/Entity Framework will write the code for you.

The code that's generated by the LINQ/Entity Framework combination is, effectively, code written by the people who designed .NET and ADO.NET. I don't know if these people are smarter than me or you (though I have my suspicions), but they do know a great deal more about how those underlying technologies work. Trust me, you want their code.

Check out my Practical .NET column, Why You Really Should Be Using LINQ, for more on this compelling data access technology.

About the Author

Peter Vogel is a system architect and principal in PH&V Information Services. PH&V provides full-stack consulting from UX design through object modeling to database design. Peter tweets about his VSM columns with the hashtag #vogelarticles. His blog posts on user experience design can be found at http://blog.learningtree.com/tag/ui/.

comments powered by Disqus

Featured

  • Compare New GitHub Copilot Free Plan for Visual Studio/VS Code to Paid Plans

    The free plan restricts the number of completions, chat requests and access to AI models, being suitable for occasional users and small projects.

  • Diving Deep into .NET MAUI

    Ever since someone figured out that fiddling bits results in source code, developers have sought one codebase for all types of apps on all platforms, with Microsoft's latest attempt to further that effort being .NET MAUI.

  • Copilot AI Boosts Abound in New VS Code v1.96

    Microsoft improved on its new "Copilot Edit" functionality in the latest release of Visual Studio Code, v1.96, its open-source based code editor that has become the most popular in the world according to many surveys.

  • AdaBoost Regression Using C#

    Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demonstration of the AdaBoost.R2 algorithm for regression problems (where the goal is to predict a single numeric value). The implementation follows the original source research paper closely, so you can use it as a guide for customization for specific scenarios.

  • Versioning and Documenting ASP.NET Core Services

    Building an API with ASP.NET Core is only half the job. If your API is going to live more than one release cycle, you're going to need to version it. If you have other people building clients for it, you're going to need to document it.

Subscribe on YouTube